subtenante wrote :
The thing is i can't get how you can make 30 classes for these 6 use
cases. I mean, could you give me an example of the classes you find in
these packages ? Do they also follow a certain sub-pattern that comes
back frequently ? For the moment, the way i see it, i would hardly
have one class in each package, which does not make that much sense.
In the folowing, a leading x is the use case name, so where you see
xEdit that could mean PersonEdit.
Editing use case:
xEdit
xEditPage
Command
Data
SQL
SQL_Microsoft
Validator
List use case:
xList
xListAll
xListPage
xListAllPage
xPrintView
xPrintViewPage
Command
Data
Row
SortOrder
SQL
SQL_Microsoft
ViewData
Where a class has a name such as PersonEdit (or xEdit above), that is
the servlet which is called by the application server (Tomcat). The
servlet takes care of all navigation and calling the Command object. By
navigation I mean that if the user clicks on Cancel, then that goes to
another page. If an error occures, then we go to that page, etc.
classes ending in Page hold page specific information such as field
names. The JSP uses these names in the field name parameter (<input
name="<%= PersonPage.USERID %>"> The Command class uses these field
names to extract the information the user entered from the request and
to place it in the Data object.
The list function will paginate the rows, that is 1-20, 21-40, 41-45,
and so on. The list all shows all the rows, and is used for printing
the list.
The SortOrder holds constants for which column is being sorted. A
column on the List page (JSP) has a clickable header cell. That calls
the xList servlet which calls the Command, which calls the SQL which
uses a case statement (using the SoftFilter constants) to generate an
"order by" clause which sorts by that column.
Command contains the business rules.
Validator validates the user input.
ViewData holds detailed information for a single row. This is displayed
below the list, and the user can click on a View button, or PrintView
SQL is an abstract class containing the methods which will be used for
SQL operations. For the Comand class to run SQL operations, it calls
SQL.getInstance(TransactionLevel). The .getInstance determines the type
of database vendor being used, and instantiates that class.
SQL_x is a vendor specific class extending the SQL class, and has the
actual SQL syntax for that vendor. If (for whatever reason) a different
vendor is used, then only this set of classes need to be re-written.
The vendor is specified in the configuration.properties file, along
with connection parameters.
So that is 19 classes.
Of course there are other classes in the framework. For instance the
Validator extends BaseValidator which has a lot of utility functions
such as checkBlank(String value), which will make sure that value is
not empty. If it is empty a message will be created which the user will
see, and isError() will return true. Same for numberRange(long value,
long minValue, long maxValue), dateOrder(Calendar start, Calendar end),
and so on.
I also use a database pool manager (proxool) which opens four
connections intitially, up to a maximum of 20. All SQL operations get a
connection from the pool, so connection overhead is minimal.