i-Lab Guide To: Design Patterns

GoF categories

  • Creational – for instantiation of objects/classes
  • Structural – for aggregation of objects/classes
  • Behavioural – for decoupling of objects/classes

Example GoF patterns

  • Creational Class; Factory Method
  • Creational Object; Abstract Factory Singleton
  • Structural Class; Adapter (class)
  • Structure Object; Adapter (object), Façade, Bridge, Composite
  • Behavioural Class; Interpreter
  • Behavioural Object; Iterator, Observer, Visitor

GoF Pattern Details

  • Adapter; Adapts one class (object wrapper) or interface (multi inheritance) into another
  • Bridge; Decouples an abstraction from its implementation so they can vary independently
  • Composite; Treat a groupd of objects in the same way as a single objet
  • Delegate; Appear to implement an API but really delegate to another object
  • Façade; Present a different interface; to simplify, abstract or reduce dependencies
  • Flyweight; Lots of lightweight objects without extraneous data (by normalisation)
  • Immutable; Cannot be changed
  • Iterator; Abstract sequential iteration of an aggregate without exposing representation
  • Marker Interface; Tagging a class to indicate some semantic property
  • Observer; Observers register for events when an observed object changes state
  • Singleton; A single instance of a class
  • Visitor; A mechanism for visiting nodes in a data structure and processing them in an abstract way

J2EE Tiers

  • Client <- Presentation <- Business <- Integration <- Resource

Example J2EE Patterns

  • Presentation; Decorating Filter, Front Controller, Intercepting Filter, View Helper
  • Business; Business Delegate, Transfer|Value Object, Session Façade
  • Integration; Data Access Object, Service Activator

J2EE Pattern Details

  • Front Controller; manages state transitions by dispatching requests without each state handler needing to know all neighbouring states
  • Transfer|Value Object; encapsulation of business-object values into a serialised unit passed by-value across the network for efficient use on the client
  • Data Access Object; generic interface to resource tier, with sub-classes for each specific implementation
  • Business Delegate; business object residing in presentation tier hiding details of interface to business tier
  • Service Locator; abstraction of JNDI look-up services to promote re-use and reduce resource usage
  • Intercepting Filter; independent filters each encapsulating a specific request processing action
  • Model View Controller; Controller (servlet), deals with Model (JBs), and presents using View (JSPs)

© 2007 i-Lab Limited