This is my first medium post, so I wanted to start with a subject that I recently work hard and enjoy while learning : Design Patterns.
There are a lot of definitions of Design patterns, but I am going to explain it with real life scenarios because as a junior, I find this technique way more effective and catchy for the beginning of new subjects.
In life we always face with some problems to be solved. Most of the time, when we share our negative situations with people, we can see that they have similar problems too. Even our parents are telling us about their experiences to make us solve the problem or never face with some specific kind of negative situations : Here it comes ! In programming developers realized that they were having same problems at some point : some problems are repeating and reasons of them are also joint . Therefore, instead of creating or applying the same solutions all the time (which causes waste of time and energy), they decided to generalize these solutions and named them as Design Patterns. Shortly; they collected their experiences and make them more adaptable, reachable and general patterns to optimize the code. Moreover, it is possible to create new customized design patterns for various scenarios.
Yes, that’s about the size of it ! If we have scenarios that the other programmers faced and created a general solution, we can use them or if we wish, we can create our own design pattern that fits our scenario. Also in the development process we can prefer to use one of design patterns : thus, our code becomes more compatible, readable, faster and our code can be more flexible (which is very important for business processes).
For an example, MVC is one of the most used design patterns. Model describes data or database systems, View describes cooked data seen to user and controller describes the layer where data is cooked. More clearly, MVC is a pattern to develop and design web applications based on a same purpose, but can be adaptable into different situations. As you can realize, MVC makes the process more flexible by standardizing it for both: user and developer. Another example is Lazy Loading which decreases the cost of creating an object is a popular design pattern too.
“The best designers will use many design patterns that dovetail and intertwine to produce a greater whole.”-Erich Gamma
Design patterns are grouped in 3 main categories :
Next time, I am going to continue with Creational Design Patterns and explain each of them with examples.
Thank you for reading! Let me know in a comment if you felt like this did or didn’t help. :)