This is a blog series is dedicated for Design Pattern and its usefulness in programming systems. We will discuss in detail about each and every design pattern. We will try to answer the most essential questions Why? How? Where? What. We will try to implement these design pattern in nodejs and golang. Writing a code is easy but when it comes to testing it become very cumbersome job to test that piece of code. We will try to test this case.
I am trying to keep each and every blog to the point so that it will not bore maximum people. The main focus of this blog is trying to answer What is design pattern and where to use it.
What and Where?
Patterns exists everywhere. Design Pattern are the proven techniques to solve a given set of problem. Yes only to the given set of problem only. Though Complex problem requires you into much simpler problem where you can apply these pattern to solve it. I will try to give you a more of a practical example to make my point more clear. For example if you have given the responsibility of designing a zoo where you can put animals and also it must support visitor where people come there and see wild animals. This is just a hypothetical design as well as open ended problem. As this problem lies more on the complex part and also inorder to scale our zoo we can break the zoo into much Smaller component like
Component 1. Zoo Prices and Tickets
Component 2. Enjoyment Station
Component 3. Animal Cages
Component 4. Joy Rides
Component 5. Restaurants
Component 6. Drainage System Now we can focus more on smaller portion and try to scale each and every small Components in the system. We can now look for the best and proved design for each and every component. This same analogy comes while programming software. We don’t just simply reinvent the wheel by designing another solution to the same problem. While designing the solution you will always have to think about the correctness of the solution. Will it work in all cases or go haywire in some situation. Design Principles comes to our help.
Benefits of Design Pattern
As it is Proven and well documented technique to solve a problem. So you don’t have to waste time to reinvent the wheel and start from scratch.
Design Pattern is language agnostic so the solution can be left for the developer/engineer to implement.
A pattern is well establishing so communication between peers becomes easy while describing the problem.
Its a tried and tested solution so reduces the complexity of the technical project
Types of Design Pattern
In terms of software development the smallest unit is an object(Chunk of memory given to a variable). I will not go on implementation part right now(Just to keep short and simple). More example and code will follow in later series of this blog. So on the basis of lifecycle of object the design pattern is broken down in more of three parts :-
Creation Design Pattern
Structural Design Pattern
Behavioural Design Pattern
Creational Design Pattern
As the name suggests it deals with the creation of the object. There are many ways to create an object for one situation. Its main objective is to provide flexibility while creating complex objects while keeping code reuse in mind.
Structural Design Pattern
Well we have created our basic unit through creational design pattern. Now this design pattern deals with combining these little units to become a large Structure. Unlike all the sub-pattern in Creational design pattern motive was to create a basic unit, all the structural design pattern has different motive.
Behavioural Design Pattern
We could have multiple structure in our project. Just take the example of zoo – we have created different Structure like Zoo-Pricing and Tickets, Restaurants, Joy Rides. This pattern provide solution about the interaction of structures among themselves so that it does not compromises the flexibility and testing capabilities.
There are different design pattern in above pattern. We will try to cover and implement important and famous design pattern in our next blog series. This blog was just a quick answer of What and Where of Design Pattern.
You can also read aout
https://www.learnsteps.com/monitoring-infrastructure-system-design/