Design Patterns are solutions to the recurring problems. There are different types of patterns. The most basic ones are the Design Patterns. Then there are higher level patterns like Enterprise Design Patterns. We can classify patterns based on different criteria. The classic Gang of Four Design Patterns (GoF) are the foundation for recurring software problems. These consists of 23 patterns which mostly deal with the low level design of software. These patterns are solutions or in fact templates for making the code more and more reusable and maintainable. One of the primary goals of design patterns is to make the software easy to modify and maintain without making large scale changes. Hence most of the Gang of Four patterns talk about adapting the software to new requirements without major modifications to the existing software. They are more into making the software flexible to adapt to new changes.
Martin Fowler and various other prominent software professionals came up with next level of patterns which don’t necessarily deal with how we design the classes and interfaces. But their patterns were based on how we use the components in broader sense. They defined the Enterprise Architectural Patterns. These patterns deal with commonly used solutions across enterprises. These patterns are still evolving and unlike the GoF patterns their origins are in different places.
Architectural patterns are based on the type of choices people make while designing or integrating their solutions. Some of the Architectural patterns are Service Oriented Architecture (SOA), REST etc. These patterns basically define how we are going to build the complete system by integrating smaller components within the scope of the application. When some one says they are following SOA, we can be sure that the business logic is abstracted into a service layer and the user interface interacts with the service for carrying out various business processes. Similarly when we hear people talking about RESTful API we know that they are taking about a commonly used REST protocol for referencing the resources over the internet.
Enterprise Architectural Patterns are another set of patterns which deal with the common solutions to recurring problems in an enterprise applications. These are collection of patterns which deal with different aspects of enterprise application. Some of the examples of enterprise patterns are using Dependency Injection and Inversion of Control container to loosely couple different components of the application. Using an Object Relational Mapper (ORM) to map entities between relational database and the business objects. Abstracting cross cutting concerns using Aspect Oriented Programming. The set of enterprise patterns are divided by different components which are used within the enterprise applications like the front end or view, middle tier or business layer and backend or persistence layer. For more details you can refer to the excellent book by Martin Fowler.
Here is my attempt to share my understanding about the patterns I have used during my professional career. Many of the examples found on the internet are very very elementary and not related to real world applications. Here is my attempt to explain various patterns as close as possible in a way they are used in real world applications. Here is a collection of posts related to Design Patterns & Enterprise Patterns I have written so far.
Strategy Design Pattern – This post demonstrates how to refactor conditional code into Strategy pattern implementation using monthly instalment for loan calculator as an example.
Factory Pattern – Using account statement dispatcher as an example this post demonstrates the how to refactor the object creational logic into a factory.
Singleton Design Pattern – Demonstrates 3 different ways of implementing Singleton Design Pattern.
Abstract Factory Design Pattern – Implementation of abstract factory using report writer as an example.
Adapter Design Pattern – An example of Adapter Design Pattern using social network client as an example.
Template Method Design Pattern – Using report writer in different format like PDF and Excel, this post demonstrates the use of Template Method Design Pattern.
Observer Design Pattern uses Portfolio Manager as an example showing how Stocks (Subject) can notify Observers like grid and pie chart about the state changes.
Observer Design Pattern with Delegates And Events demonstrates the Portfolio Manager solution refactored from earlier post using Delegates and events capabilities of C# language.
Prototype Design Pattern – Using an example of Store creator this demo shows how to simplify the object creation using prototype Design pattern
Decorator Design Pattern – Based on the concept of an order manager with various combinations like domestic orders or international orders including shipping, gift wrapping, personalizing as additional attributes, this post demonstrates the use of Decorator Design Pattern.
State Design Pattern – Using Personal loan as an example this post demonstrates the use of State Design Pattern to depict how the behaviour of an object changes based on the internal state of an object.
Facade Design Pattern – Using housing loan as an example, this post demonstrates the use of Facade pattern to simplify the various sub-systems used to verify different details.
Builder Design Pattern – This post demonstrates the use of Builder pattern using a bill generation as an example.
Composite Design Pattern – Uses an example of profit calculator at different levels like Store, State, City etc. to demonstrate the Composite Design Pattern.
Specification Pattern – Specification pattern implementation using LINQ. This post demonstrates the use of specification pattern to filter a products collection based on various attributes like Color, Price etc.
Here are some books I recommend related to the topics discussed in this blog post.