Shortly a developer asked me, what are the most know-worthy patterns - in context of Java EE. My answer was:
- Facade: it decouples independent classes, and more important, decreases (makes the interface more coarse grained) the granularity. Session Facade from Java EE is a sample.
- Adapter: makes incompatible things compatible. Especially important in server programming, in case you have to talk to legacy backend systems like SAP, CICS or IMS. Business Delegate in J2EE 1.4 (catches RemoteExceptions and throws something else), DAOs or JCA Connectors are adapters.
- Decorator: Enhances an interface (in our case the Facade), with additional aspects (it is actually the beginning of AOP :-)). In Java EE we have the Servlet Filter, Interceptors or implicit decoration with transactions, state or security. In Java SE the whole java.io package is a decorator.
- Interface (actually not a standard pattern): is needed for encapsulation, decoupling the clients from the interface realization, and so is the beginning of service orientation or SOA.
- Factory/Builder: encapsulates the creation of differnt implementations for a Java-Interface. Can be a part of a framework (see Spring or Java EE 5), or of project architecture.
- Command: provides a simple and stable interface (often one method with name like execute, go, run, actionPerformed etc). The implementation provides the behavior, having the only the interface, it is not possible to see what happens :-). Command is the foundation of JMS, the whole SOA (stands for Same Old Architecture :-)) and also the event handling of frameworks like swing (ActionListener), or Struts (Actions).
Business Delegate (Adapter + Factory) ------> Decorator (Transactions, Logging, Security) + Session Facade (Facade), a bunch of POJOs or Session Beans, and some DAOs (Adapter) or connectors to the backends. Message Driven Beans (Command) are often used for batch processing.
It's amazing, but it is possible to build almost every (Java EE) architecture with these building blocks.
NEW: Online Workhop Effective WebApps without Frameworks is also coming to: MUC Airport.