Makes the application easier to maintain. Each tier in an application is unaware of the implementation details of any of the other tiers.
Enforces a layered, closed architecture where each tier can only speak to the tier below it.
Even when speaking to the tier below it, the upper tier only speaks through well-defined interfaces to the lower tiers. We try never to expose the upper tier to any implementation details of the lower tier.
Tiers are a logical division of labor and do not necessarily denote that the application has to be physically separated onto three distinct pieces of hardware.
J2EE Architecture & Design Patterns (p. 4)
JDBC Session 5 Categories of J2EE Design Patterns J2EE Architecture & Design Patterns (p. 5) Presentation Tier Patterns Business Tier Patterns Integration Tier/Data Access Tier Patterns Intercepting Filter Front Controller View Helper Composite View Business Delegate Session Façade Value Object Assembler Data Access Object Value Object Service Locator
JDBC Session 5 Typical J2EE Design Patterns Implementation J2EE Architecture & Design Patterns (p. 6) Front Controller Business Delegate View Helper Integration/ Data Access Tier 1. 2. 3.
Front controller takes incoming user request and decides what to do with it.
Business delegate is the business logic responsible for processing the user’s request.
View helpers are responsible for rendering the output that is sent back to the end user.
JDBC Session 5 The Business Layer J2EE Architecture & Design Patterns (p. 7) Business Delegate Session Facade Business Objects
A business delegate hides the mechanics of how a process is invoked. The developer using the delegate does not know if they are using an EJB or a web service.
A session façade wraps the individual classes that carry out an entire business process.
The business objects are fine-grained objects used in carrying out the process.
Session Facade Session Facade 1. 2. 3.
JDBC Session 5 The Data Access Layer J2EE Architecture & Design Patterns (p. 8) Data Access Object Data Access Object Data Access Object Value Objects
A business object will retrieve and manipulate data using a Data Access Object. (DAO)
A DAO will encapsulate all of the CRUD logic (Create, Replace, Update, Delete) in the application.
All data sent to a DAO or retrieved from a DAO will be encapsulated in a Value Object (VO)
In the enterprise, applications come and go, but the data in these systems lives on.
A persistence framework defines a standard set of interfaces for retrieving and manipulating data. Code re-use often comes from interface re-use.
A well-defined data access tier is often times one of the most re-used pieces of code within the enterprise.
Stick to your implementation. Do not let time constraints compromise the integrity of your architecture.
Architecture and J2EE Pattern Usage has to have a business case. Using patterns for the sake of patterns is self-destructive.
Designing a Framework (p. 2)
JDBC Session 5 DAO’s: Not just about Relational Databases: Designing a Framework (p. 3) MemberDAO Relational Database JDBC MemberDAO Java Data Object JDO MemberDAO SOAP envelope Web Service MemberDAO XML (Xindice) XPath