Design Patterns - I (Introduction)
A Seriers to understand Design Patterns Completely
Authoring software requires a set of rules and methodologies to take your idea to center point without any rework for future enhancements. In Software Engineering, we have a set of principles stated by Robert Martin called SOLID principle. SOLID word has principles as Single Responsibility, Open Close, Liskov’s Substitution, Interface Segregation and Dependency Inversion. Let me explain you about SOLID as one word
SOLID
Single Responsibility Principle – There should be a one strong reason to change the class.
Open/Close Principle – Entities should open only for adding new functionality and Close for any updates after testing phase.
Liskov’s Substitution Principle – Functions accessing base class must be able to access derived class
Interface Segregation Principle – Clients should use Interface members completely.
Dependency Inversion Principle – High level modules and Details should depend on abstractions only.
Other Main Principles of Software design Engineering is
Dry (Don’t Repeat Yourself): Code should occur exactly once in the system.
KISS (Keep it Simple, Stupid!): Unnecessary complex code should avoided.
YAGNI (You ain’t gonna need it): Implement the things when you need them
These principles results to maintain your software code as manageable, Scalable and reusable code and results in faster development.
In point of code reusability Design Patterns are introduced. Design patterns are introduced by Christopher Alexander in 1977, Kent Beck and Ward Cunningham in 1987. Design patterns are considered as reusable solutions for commonly occurring problems in software designs. Advantages of design patterns are, they provide solutions for commonly occurring problems in software designs, they can implement in any language, provide standard terminology and specific to particular scenario. Design Patterns are categorized into 5 categories.
Creational Patterns
Structural Patterns
Behavioral Patterns
Model – View – Controller Patterns
Concurrency Patterns
Creational Patterns:
Creational Patterns are patterns deals with object Creations. Creational Patterns are applicable when:
A system should be independent of how its objects and products are creating.
Two or more objects designed to use each other.
Instance, can be extended without modification.
Sub class of a class wants to access class object.
Reveling interfaces of a product.
Constructing different independent Complex objects.
Single instance can be access all the time.
Structure of these creational patterns contains creation followed by its concrete creator. Creation Patterns group contains 7 Design patterns.
Abstract Factory
Factory Method
Builder
Lazy Initialization
Object Pool
Prototype
Singleton
Structural Patterns:
Structural Design Patterns are used to define entity relationships in simple ways. Structural patterns use inheritance to compose interfaces or implementations. Structural patterns are useful to develop independent class libraries to work together.
Structural Patterns has 11 Patterns with it.
Adapter
Aggregate
Bridge
Composite
Decorator
Extensibility
Facade
Flyweight
Pipes and filters
Private Class Data
Proxy
Behavioral Patterns:
Behavioral Design Patterns identifies common communication between objects and realize these patterns. These patterns increase the flexibility of communication between the objects.
Behavioral Patterns has 19 patterns.
Chain of responsibility
Command
Externalize the Stack
Hierarchical visitor
Interpreter
Iterator
Mediator
Memento
Null Object
Observer
Weak reference
Protocol stack
Scheduled-task
Single-serving visitor
Specification
State
Strategy
Template method
Visitor
Model-View-Controller:
Model View Controller design pattern has its own identity which has 3 inter connected parts, Model, View and Controller. We use this mainly for User Interfaces.
Concurrency Patterns:
These Patterns mainly deals with Multi thread Programming. They were associated with Pattern Oriented Software Architecture. Concurrency Patterns have 11 Patterns.
Active Object
Balking pattern
Double checked locking pattern
Guarded suspension
Leaders/followers pattern
Monitor Object
Reactor pattern
Read write lock pattern
Scheduler pattern
Thread pool pattern
Thread-Specific Storage
……To be Continue
References:
-
http://www.codeproject.com/Tips/654769/Software-Design-Principles http://www.dotnet-tricks.com/Tutorial/designpatterns/RPW2250513-Different-Types-of-Software-Design-Principles.html
- http://en.wikipedia.org/wiki/Software_design_patterns