My program works ok but recently I have been thinking of refining the design
patterns and the placement of the business logics.
In the booking method, we have to know the column index to find out which column is the Flight no, Origin, Destination, available tickets, etc...
How do we locate that column index in the table ?
eg. on the server side
int findFieldIndex(
String columnToLookFor){
FieldInfo[] fieldInfo = getFieldInfo();
int i = 0;
while (i < fieldInfo.length) {
if (fieldInfo[i].getName().equals(columnToLookFor))
return i;
i++;
}
return -1;
}
In the booking method (on serverside), say i need to find available seats....so i call findFieldInfo("Avaialable Seats")
Do you think it there is a way to do it without hardcoding "Available Seats") on either the client or server side.
if not, is it better this method to put it on the server side ?
I have been think putting this on the server side because if the database schema changes, it will not affect the client program. Modification is needed only on the server side.
As well for the booking method, if i placed it on the server side, it appeals that it becomes more atomic and resistance to client disconnections.
However, I need to add an method in the remote interface and the remoteImpl in order to do that. Should such helper method be placed in there or should I simply it in the GUI as a helper method (but i don't think it is a good idea), or other places ?
In short, I added 2 helper methods, "booking" and "findFieldIndex" on the server side, Any comments ?