What is Design Pattern ?

IntroductionπŸ€”πŸ§ πŸ’‘

I found myself repeatedly questioning, "What is a design pattern, and why I should use it ? ". 

The professor said that using design patterns makes our code more readable, cleaner, and easier to maintain. Despite my efforts, the concept remained abstract and unclear. 

A concise and insightful quote by Christopher Alexanderwell-known architect, who pioneered the concept of design patterns, clarified the idea for me. He explained that 

'Each design pattern can describe an issue which happens again and again in our surrounding. Then, it also describes about the fundamental solution to that problem. In this way, you can use this solution a million times over, without every doing it the same way twice.'

This quote helped to illuminate my understanding of design patterns, enabling me to better grasp their importance and application. 

Who created design pattern ?

Christopher Alexander, the father of design pattern - an architect, built design pattern for building architectures in 1977.

Later in 1995, design patterns for software designs were created by 4 software designers & engineers - Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, known as "Gang of Four". They wrote a book named "Design Patterns: Elements of Reusable Object-Oriented Software" which include 23 design patterns for Object Oriented Software Design.


My Definition of Design Pattern

Let's define design pattern as a blue print that is reusable to solve common problems that many programmers may definitely face in handling a program. Using design pattern cannot solve your coding errors or bugs, but it can provide a conceptual structure of your program which is easily understandable, reusable, and easily maintainable. 


Is that all reasons why I should use design pattern ?

Yes exactly. Let me give you an example. ☝

In real world projects, hundreds or thousands of classes or codes have to be written.  Moreover, when we work with a group of developers team, each needs to understand code written by others. 

Without using design patterns, most classes and code will become tightly coupled, making modifications and updates challenging. For example, if you need to rebuild a class or make a small change in the software, it could require updating numerous other interconnected components. This can be time-consuming and frustrating. 


So what happen if I do not use design pattern ?

Well, it will probably decrease the performance of the system since the implementation cannot be reusable, reduce productivity, and increase complexity. This is a reason why developing design patterns is necessary in any software development. It is not mandatory but essential thing you need to do to be a good developer.

'Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. as written in Design Patterns Elements of Reusable Object-Oriented Software.'

I would amend it to say, 'Fixing a software bug, only to later forget how you fixed it, is even more challenging.'


Nowadays, many programming languages provide frameworks that follow specific design patterns. Therefore, when using a framework, it is not necessary to implement a design pattern from scratch. However, understanding the concepts behind design patterns can give you a deeper insight into how the framework works. On the other hand, if you are working with a pure programming language such as PHP, Python, or Java, applying design patterns can significantly improve the maintainability and scalability of your project—especially in large team-based or corporate projects.


Design Pattern & Object Oriented Programming

For Object Oriented Programming, design pattern can be used as a technique to organize object creations, their structures and behaviors. Depend on the system requirement, there are three major design pattern types, Creational design patterns, Structural design patterns and Behavioral design patterns. 



In next post, I will discuss detail characteristic of each design pattern and how to apply them into your project ...


x

Comments

Popular posts from this blog

Distributed Version Control System - Part 1

Distributed Version Control System - Part 2