Designing Enterprise Applications – Approaches and Patterns

JavaWorld has published a useful research paper which discusses how to discern which design patterns and frameworks would work best for your enterprise applications, written by Chris Richardson. As a developer it is very essential to know about the different strategies one would adopt in a particular business scenario. This paper helps you in making important decisions about which design patterns would best suite a given set of requirements.

According to the research done by Chris for enterprise applications, here are some of the important points which the paper elaborates:

  1. Make use of the POJO approach, with lightweight frameworks like Hibernate for ORM and Spring AOP for transactional activities.
  2. EJB 3 makes it possible to have your business logic sit within your POJO and also make it run outside the container which makes it really usable.
  3. Implementing 3 tiers for an application which commonly include
    1. Presentation tier
    2. Business Interfaces for encapsulation + Business tier logic in classes
    3. Persistence tier for handling transactions and concurrency
  4. The design should involve,
    1. Modeling your business classes appropriately
    2. Code structuring principles for easier maintenance

While the above points are usually very well known amongst the developer community, it helps if you know which decisions should be taken when. Design patterns which have been established over the years play a key role in making such decisions. The white paper explains a few of the design patterns which are particularly mentioned when enterprise applications are into consideration.

I would like to enumerate here, some of the different design patterns which are highlighted in the paper, according to the decisions which fall into 3 main categories.

Decision #1 – Organizing Business Logic

When you have to implement the business logic it is very important to identify the scope and the scale of the application to decide one or the other approaches as stated below,

Transaction Script Pattern:

  1. Does not follow the object oriented principles
  2. Methods are mapped to application request from the presentation tier, which are called as Transaction Scripts
  3. Follows the procedural approach which makes classes less important and methods more important
  4. Simple to implement but difficult to understand and maintain the code
  5. Mainly used when business application is small

Object Oriented Approach:

  1. Maps the objects from real world to the application
  2. Easier to understand the application logic
  3. Behavior and state are encapsulated inside the mapped objects
  4. Lightweight frameworks help to apply this approach to your application.

Table Module Pattern:

  1. Involves mapping of database tables to business classes
  2. An object of a table includes all rows of the table rather than a single object mapped to one row
  3. It suffers from the problem of maintenance.


Decision #2 – Encapsulating of Business Logic

Well designed Business applications always encapsulate logic from the view. This helps in application scalability and security, at the same time providing loose coupling between the different tiers. The patterns which can be adhered to encapsulate business logic are:

Session Facade Pattern:

  1. Promotes proper encapsulation of business level logic
  2. Handles transactional behavior, security and presentation tier requests
  3. Does caching of objects to prevent memory overloading in case of many requests
  4. Delegates requests to proper business objects
  5. Was earlier implemented by using EJB 2 Session Objects
  6. It is heavy on memory and time consuming for testing and development

POJO Facade Pattern:

  1. Business logic encapsulated within simple POJO’s
  2. Easier to develop and test and can run outside the container
  3. Transactions , security and state can be maintained through AOP
  4. Spring framework uses this pattern
  5. Light on memory
  6. Makes use of Dependency Injection for wiring the business classes instead of using JNDI

Exposed Domain Model Pattern:

  1. Used to avoid extra code for designing the facade
  2. Presentation tier can directly access data objects
  3. Makes use of AOP to access business objects without an intermediate facade layer
  4. Drawbacks include the requirement of transactions and data handling by presentation tier
  5. Risky since presentation tier can directly manipulate persistent data.


Decision #3 – Database Access

The decision of accessing data is of strategic importance since IO has a major impact on application performance. So apart from making a decision on the databases and normalization it is crucial to have the best approach for accessing it from other tiers in the application. The paper emphasizes that,

Direct JDBC has drawbacks such as:

  1. Boiler plate code for handling connection and fetching of data
  2. Database specific SQL reduces the portability of the application
  3. Maintenance of low level SQL poses problems from schema changes
  4. Can be of advantage when vendor specific features have to be accessed

To overcome the disadvantages of JDBC, using a framework like the iBATIS Framework can be advantageous since:

  1. Direct SQL queries can be used
  2. Provides mapping between resultsets and Java Beans through XML descriptor

The Advantages that Persistance Frameworks offer are:

  1. Mapping of data to domain objects
  2. No need to write SQL code
  3. Flexibility offered by configuring XML descriptors for domain level objects and data
  4. Loading & updating of database as and when required
  5. Transactions and concurrency are handled by the framework

Enterprise applications should be modeled and designed properly from the early phases itself. Without following proper approaches from the ones mentioned above can be an invitation for trouble. I hope that these approaches help the developers to come up with good designs for enterprise applications.

3 thoughts on “Designing Enterprise Applications – Approaches and Patterns

Leave a Reply

Your email address will not be published. Required fields are marked *