HeadStart System Design — Design Pattern Intuitions

HeadStart System Design — Design Pattern Intuitions

Intuitions about which Design pattern to use based on the input you have providing and the functionality you want. The other day, a friend asked me on how I go about choosing a design pattern in a given scenario, because it was not always very clear.

The other day, a friend asked me on how I go about choosing a design pattern in a given scenario, because it was not always very clear.

Some design patterns are similar in terms of functionality (i.e. factory vs. builder)

I presented my intuitions via chat, and at the end of the discussion we both realized that with these intuitions for some of the design patterns in mind, choosing next time among them will be easier.

Hence, I thought of documenting and sharing it with everyone.


Say that you are shopping from a factory outlet of a clothing company. You will only get t-shirts based on the size grades i.e. S, M, L, XL etc.

Hence, single input from our side i.e. S, M, L, XL etc. will define the whole t-shirt.

Similarly, when you want to specify a single input argument like a keyword or an _**_ENum_, and get a variation of the main _abstract class/interface TShirt __created for you like __SmallSizeTShirt_, then you should go with _Factory**_ pattern._

Similar example is covered here, with abstract class/interface Person and its custom variations Villager and CityPerson created for use that are created on the basic of a single input, the enum PersonType.

Image for post

Factory Design Pattern in C#. Source: Wikipedia


Now say that instead of going to a factory outlet, you want to have something that fits you better, so you went to a tailor for custom tailored shirt.

Now, the tailor will take note of various other inputs like your chest size, your arm length, your shoulder length etc.

Hence, you can see that the tailor doesn’t have grades based on only one input like size, instead he has a number of input parameters and is makes unique shirts for each customer based on the input values for each of them.

Here, tailor is synonymous with a builder.

Hence, when there are multiple inputs from your side to construct a variation of the main _**_abstract class/interface Shirt_, use _ShirtBuilder_ to return a _CustomShirt**_ for you based on various inputs._

Similar example is covered here, with ICarBuilder using various inputs like NumDoorsColourBrandName and ModelName and some code logic to construct a Ferrari 488 Spider Car.

design-patterns system-design-interview java python software-engineering

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

My System Design Interview Checklist in 8 Simple Steps

That dreaded system design interview. I remember the first system design question I was asked. “Design WhatsApp”, he said. I didn’t know where to start! I was a fresher. Data structures and algorithms were the only things I knew. I am sure you can guess how that interview went. Then after enough research, I made myself a checklist of components, of sorts, to navigate me through my next system design interviews. And I sh*t you not, it works!

Proxy Design Pattern in JAVA

In this blog, we will discuss Proxy Design Pattern, its example, and how it is different from the other design patterns. But, it’s important to have an understanding of the design patterns first. You can refer here.

Design Patterns — Decorator Design Pattern

The decorator design pattern is a software design pattern that helps you add responsibilities to an object at runtime. This pattern is considered to be a structural design pattern. This type of pattern focuses on the relationships between classes and how they can help solve specific problems.

System Design Interview Tips

The system design interview provides the key signals that differentiate a tech lead from programmers. Here’s some tips may help you ace it. ![Image for post](https://miro.medium.com/max/753/1*NZGjsIPEFwTxgfyBy_AUZA.jpeg) Image...

Software Developer vs Software Engineer — Differences: Bogus or Real?

In this article, see if there are any differences between software developers and software engineers. What you’re about to read mostly revolves around my personal thoughts, deductions, and offbeat imagination. If you have different sentiments, add them in the comment section, and let’s dispute! So, today’s topic…