Categories
Design Pattern

What is Design Pattern

Software development is an art of programming. But we don’t always write code from scratch we often copy paste code blocks. For example once we learn how to read text from file, we will continue to apply same logic at point of time later. That means reusing our learning. But is development is also about designs. What if we want to sort numbers, surely we will think about algorithms like bubble sort, heap sort etc. That means we reuse already learned logical solutions to same problem.

Design pattern is also same thing, it is collection of logical solutions to day to day design problems. Factory pattern tells us how to design construction of objects, iterator pattern tells us how to design iterator for iterations etc. Just like algorithms are aimed at minimizing complexity of solutions. Design patterns are aimed at following

  1. Reusability of code – same class or method to be used at multiple places.
  2. Minimum exposure of code to changes. – If we put creation logic in factory class, we will modify factory class only for creation class. No need to touch code where iteration logic is written.

Design patterns are classified into following categories

  1. Creational patterns
  2. Structural patterns
  3. Behavioral patterns

Leave a comment

Design a site like this with WordPress.com
Get started