Design Pattern, is a general reusable solution to a commonly occurring problem within a given context in software design. Design patterns help you show the path how the similar problem was solved. Each Design Pattern should have a correct NAME, INTENT and MOTIVATION. Name of the Pattern help you understand what problem it is trying to address, Intent will help you dig deeper into it. Motivation of this pattern might help you understand the scenario / context when you can apply this pattern. There are too many patterns available in the industry they are broadly divided into these categories.
These are the categories of GoF Patterns( Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides). The best book to read about these Design Patterns is – Design Patterns: Elements of Reusable Object-Oriented Software written by GoF (Gang of Four).
Apart from these categories, we have different categories like Architectural patterns, concurrency patterns, Integration Patterns, J2EE Patterns etc.
Below is the quick reference of Design Pattern and It’s example and the keywords you should be able to remember to figure out the pattern. This list helps you easily figure out the pattern which you can apply in the scenario you are looking for.
Note: This notes is not for a person who doesn’t know Design patterns. This is more like a quick reference guide to refresh your Design patterns. I hope my notes would help you all.
|Pattern Name||Example||Keywords to Remember|
|Family of Factories||Different sub types|
|– Factory Method||XML reader create||No Dependencies in creation|
|– Factory||JDBC driver initialization||Common Dependencies in creation|
|– Abstract Factory||ADO .net provider factory||Sub type specific dependencies to create|
|Builder||String and String buffer||Different ways to create same object|
|Prototype||Clonable Impl of java||Clone / re use construction logic|
|Singleton||Configuration Manager / Cache Manager||Only one instance|
|Multiton||HTTP Session||Context specific singleton|
|Adapter||Java connector Architecture, Power Adapter, Display Adapter
SQL Data adapter in DB
|Not compatible, Integration, External, conversion, 3rd party|
|Bridge||DB Manager class using IDB connection instead of SQL Connection,
USB 2.0 specification, Mobile SIM interface
HTTP 1.1 specification (Browser /Web Server)
|Permutations n combinations, specificatons|
|Composite||XML tree||Tree, Hierarchy|
|Decorator||IO Streams, CSS styling||Add more to Objects|
|Facade||Controller in MVC, System/ Car startup, coffee vending machine, money transfer btw accounts, Orchestrator||Co-ordination, Hide the complexity|
|Fly Weight||Pool (Connection pool, thread pool etc)||Re use fine grained Obj, pooling|
|Proxy||Internet proxy server, Download Accelerator, web Service Proxy||Add more to types, wrapper without breaking compatibility|
|Chain of Responsibility||AC filters, Exception handling, supply chain management, event bubling, servlet filters, server.transfer in jsp||pipe lined work, Hierarchical execution, do and delegate/fwd|
|Command||JDBC statement. execute(DML, DDL, DCL), struts actions in controllers||set of actions to be executed|
|Iterator||For Each loop, Iterator interface impl, JDBC result set, Video Streaming, Agile development, paginated results||Step by Step or phase by Phase|
|Interpreter||Expression evaluation, Rule validation||lexical analysis ,Rule Engines|
DB transactions, windows hibernate, restore points, backup and restore DB,
versioning systems, undo/ redo in word, back n fwd in browser
|Maintaining State, Restore,|
Distributed transaction coordinator, JTA/ JTS (java transaction) Real estate/ Stock brokers, controls communication between windows apps, bit torrents, chat clients/servers, iCloud to sync the data, mobile service providers
|Data Exchange with different formats|
|Observer||DB triggers, fire alarms, mouse and keyboard Events,||Eventing, notification|
|Strategy||Collection uses comparable interface to compare different types of sorting, different types of credit card validation algorithms, different compression algos,||Defining interfaces, stopping “what if” analysis|
|State||Water object behaves differently in solid and liquid states, actors and roles, DB and TCP connections states, Bank A/c or Membership card state(gold,silver etc)||
Changing behavior of an Object
Avoiding if condition based logic
|Template method||Servlet life cycle||Life cycle|
|Visitor||GC of JVM||Repeated jobs with involvement of external components.|
All your feedback is welcome.
Happy Reading 🙂