Introduction to Design Pattern
In this post i want to explain what design patterns are and how they can help us.
Many of software engineers think the starting point of Design Patterns is the Book “Design Patterns Elements of Reusable Object-Oriented Software” that has been written by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. They are known as Gang Of Four (GOF), But the first time Patterns started with Christopher Alexander, a Professor of Architecture at Berkeley, So Patterns first stated in Architecture field not in Computer science. If you like to know more about his patterns and solutions you can read there two books : The Timeless Way of Building and A Pattern Language.
There are many advantages to use design patterns, Here you can see the most important reasons:
- Common Vocabulary : Design patterns can help to your team and all of the software engineers that you collaborate with them to have common vocabularies which can enhance the understand of your problem and you solution. As as example when you don’t know patterns maybe you will explain a solution with these sentences:
“I changed all of the constructors of my class to private and then i create an static field of my same class, then i add a getter method that will pass created static object every time a client call my getter, so i can be sure i have just one object from my class in all of my system”. Everything is ok but how much effort must you pay to understand the meaning of your colleague? Instead of this explanation your colleague could just say: “I used Singleton pattern for creating object x”.
- Common Problem so There is Common Solution: Many of the developers like to think about all the problems they face with them, But don’t forget many of the problems has a common solutions, you are not alone with them and they are not just yours. If you use Common solutions for your problems your code will be more clean and unstrastanble for other developers. In the other side you can focus to your design and you domain specific problems.
- Transition from Implementation to Design: When you want to present a solution and you don’t have common vocabularies you had to explain the details of implementation, as a consequence you will miss your abstraction in design time and you should talk about objects, their relations and other implementation time issues.
Design patterns in object oriented world can be divide to three different categories:
- Creation Patterns: These patterns are known as Factory Patterns, These kinds of patterns are about the conventional patterns about the objects creation problems and common solutions for them.
- Behavioral Patterns: These patterns are about how we can change, enhance, extend , etc. behaviors of the objects.
- Structural Patterns: These patterns are about how we can present solution for structural problems of objects.
Nowadays there many augmented patterns in various domains of software engineering, Enterprise Integration Patterns, Service Oriented Architecture Patterns, Software Architecture Patterns are just some examples.
I will explain design patterns one by one in my next posts. Now i hope you have a clear understanding abut design patterns, please contact me if some where is not understandable or clear for you.