banner image 1 banner image 2

Introduction to Design Patterns

June 29, 2022
3 mins
command
blog-img 1
Sai Viswanathan
Author

The Why, What, and How of Design Patterns

By Sai Viswanathan, who doesn’t just breath air, he breathes programming.


Design Patterns
Design Patterns

Background

We software engineers write million lines of code that suits our application needs and take pride in that. And, you might have often seen the code that exceeds thousands of lines in a single file. Well, there are cases where your business logic is more complicated than what you anticipate which lets you keep writing an essay, sorry programming. There could also be cases where you knowingly/unknowingly repeat the lines of code.

Refactoring often solves this problem where it helps to reduce the number of lines in your code . But, the process of Refactoring cannot be done just like scissoring your lines of code equally and making it small in size. In fact, Refactoring is not just about trimming your lines of code. It should follow design principles, adhere to commonly used design paradigms etc., Design Pattern is a way of achieving this. Let’s see how it is.

Explaining Design Patterns

Like human being, software engineering, its principles and techniques are also evolving day-by-day. Our engineering forefathers had faced a similar set of problems which I mentioned above and even complicated than that. So, they used various OOPS concepts, mix it in the right proportion and formulated a solution that suits certain problem patterns. As the name implies, its a design solution that solves a particular problem pattern. Hence the name arrived, Design Patterns.

Let’s see how we can phrase the definition that looks like an answer to a 2-mark question in your school/college exams:

Design Patterns are typical solutions to common problems in software design. Each pattern is like a blueprint that you can customize to solve a particular design problem in your code. It represents the best practices evolved over a long period through trial and error by experienced software developers.

Types of Design Patterns

Design Patterns are widely used in OO environment which means it deals with objects at different levels. It could either be involved in creating your objects, establishing relationship or building communication between them. So, these are the three different types of design patterns.

  1. Creational (C ) — focuses on object creation
  2. Structural (S) — establishes relationship between objects
  3. Behavioural (B) — building communication between objects
Types of Design Patterns
Types of Design Patterns

Now that we know the types of Design Patterns, let’s dive into each pattern separately in the upcoming series of blogs. In this journey, I will also take you through some of the examples that we’ve incorporated in our applications. Before getting into it, I would suggest you to brush up the S.O.L.I.D principles.

So, aarambikalangala? Shall we start?


References

[embed]https://refactoring.guru/design-patterns[/embed]

https://www.baeldung.com/design-patterns-series


Meet the team!

Author
Sai Viswanathan

Editor
Mridula Saravanan


We at CaratLane are solving some of the most intriguing challenges to make our mark in the relatively uncharted omnichannel jewellery industry. If you are interested in tackling such obstacles, feel free to drop your updated resume/CV to careers@caratlane.com!
blog-img 2

Discussions

blog-img 3
5 mins
May 17, 2023
Sharing Data Between Controllers: Best Practices S...

This article will help you to understand the diffe

By Naveen C

blog-img 3
5 mins
March 21, 2023
Understanding Auto Layout and Constraints in Swift...

This article gives you an easy way of understandin

By Ramasamy P