Thursday, July 3, 2008

Design Level Concepts in J2EE

Importance of Business Classes, Validations and Exception Handling:

Use rollback in Business Methods:

Perform the set of transactions together in the business component and rollback if any one of them fails. This method is called “Either All or None”.

Where to throw Exception:

It is a good idea to throw exception in business methods (in action classes in struts or in business components where the exception is caught into action class).

Where to make the validation:

The validation needs to be done always in business class. Because, there are plenty of crooked ways in poorly written application to get through validations. So one has to write the validation routines in business classes to ensure the valid database updates. For simple validations, you can prefer javascripts.

How to simplify the Exception Handling:

Use common exception defined in deployment descriptor (web.xml) or in struts-config.xml. Because all the applications are comprised of so many components where the same validations need to be performed again and again. So to bring in the simplicity and the consistency, it is better to have this common exception handling across the different components.

Where to place the queries:

It would be better to collect all the SQL named queries in a property file and to provide mechanisms to parse these and use.


Why does one need ‘Common Standards’ for specific application?

When 10 developers are involved in a team and assume there are 10 teams working for the company, then there would be easily 100 different coding styles and it would definitely lead to the complexities during the maintenance of the application. If this is not resolved early, it would lead to very expensive in future to handle. So it is always ideal to sit, discuss and frame the design standards before developers start their work.


What is the way in which the message/warning could be displayed?

Selecting the criteria and providing the results can happen in the same page, may be different layouts could be used. The search would either fail or pass and hence both success and warning message should be displayed in the page along with the result. The messages should be very precise and clear for the user to understand. For example,

The phone number of the user John has been changed to 98xxx9x80x;
The password has been changed successfully; etc.,

There are lot of design issues that may happen in the application. We will see all that and try to resolve it. Thanks for your visit and see you tomorrow. Until then Bye.

Best Regards,
Swathika.

3 comments:

Think Big said...

Hi Swathika,

nice attempt.

Unknown said...

Thanks for sharing and exposing the common issues to take care during the design phase

MariMuthu Rajagopal said...

Really useful article for software designer and developer. post more links and books about software design pattern. we faced the same problem while Re- engineering our product like coding standard, java script validation ,Exception handling ,sql commit roll-back.

thanks Swathika for your proper documentation , bit falls in design pattern.