Why do recruiters love Design Pattern interviews?

Tram Ho

Walking lessons

Hello everyone, it’s me, an IT guy who likes to share knowledge with everyone

For me, sharing knowledge not only helps readers discover new knowledge, but also helps me review my knowledge as well as recognize the wrong knowledge that I thought I had understood before. . My articles are written based on the process of learning, working, and summarizing over the years

Knowledge is vast, cannot be learned, but can only be accumulated every day so that the amount of knowledge is filled. So, what new amount of knowledge do we accumulate today? That’s the Design Pattern

I bet there are many of you here who know a lot of patterns, even I know dozens of patterns. I know that but how many templates have you applied to your project???

My Leader once said: “Many men who know a lot of Design Patterns and when they ask me, they always answer but never apply”, that’s right guys, knowing is one thing, understanding is one thing, but applying is not yet another thing. another story

The following is an overview of the Design Pattern. We answer according to 3W: What – When – Why

Design Patterns

What is Design Pattern?

Design is Design, Pattern is Pattern, which translates to mean Design Pattern. It sounds strange, am I a Designer or an architect to design anything? I never heard of it when I was in school, and my teachers didn’t teach me this, so when I went to interview any recruiters I liked to ask about it.

Hmm, so what is it that we programmers all need to master (sounds fierce, exaggerated, but it’s really important guys)

Design Patterns are general solutions that have been optimized for application in software development, these solutions are the quintessence of experienced software engineers. That’s short, but there are 2 ideas that we need to worry about, the first is to be optimized – these solutions have been tested and verified, you just have to choose the right solution and apply it to your needs. The system, the second thing is that it is drawn from experienced people – this is important, like going to work but getting senior men only have a few good tips.

When to use it?

When you find your project has problems that most other projects have

When the project starts to grow and become complicated

When you want your project to be more disciplined, more standard

Why should and shouldn’t use it?

Why use it?

Experience from the forerunners : Design Pattern is the result of accumulated experience from veteran software engineers. Using Design Patterns helps me access knowledge and experience from my predecessors, avoid common mistakes, and apply proven methods.

Common Voice : The Design Pattern provides a common language for discussing issues. It helps developers to communicate more effectively, share knowledge and ideas, and better understand the design of the system.

High flexibility, extensibility and reuse : Allows you to easily change, extend and reuse the source code without affecting other parts of the system

Testability : You can easily test functions/modules one by one without affecting other parts of the system.

Why shouldn’t it be used?

Design Pattern applied to a large system helps to reduce the complexity, but if applied to a small system, it increases the complexity because:

Unnecessary complexity : Using the Design Pattern can increase the complexity of the source code with no obvious benefit. Design Patterns require you to apply complex rules and structures, and this can make source code difficult to understand and maintain.

Increased time and effort : Using Design Patterns requires time and effort to apply and implement them. Time and resources for projects are limited, and applying the Design Pattern can increase development time and impact the project.

Advanced knowledge : Using Design Patterns can make the source code more complicated for new programmers to the project, some Design Patterns require in-depth knowledge and experience to understand and implement . If you are not familiar with the Design Pattern or do not have enough experience, understanding and maintaining the source code becomes much more difficult.

🗯️ Hope the above 3W is enough to answer the question Tại sao các nhà tuyển dụng thích phỏng vấn Design Pattern?

Main groups

In Design Patterns, there are many different types of patterns that are used to solve specific problems. These patterns are divided into 3 main groups as follows:

Creational Patterns

Provides an efficient and flexible way to create objects. These patterns help to hide the specifics of object creation and provide a way to create objects without depending on the concrete class.

Patterndescription
SingletonEnsures that only a single instance of a class is instantiated, this instance is used as a global object
Factory MethodProvides a method to create an object without knowing the details of how it was created or implemented
BuilderCreate a complex object step by step through the use of multiple pipe methods. When initializing, you can optionally use methods to set the properties and structure of the object

Structural Patterns

Gather objects and classes into a larger structure

Patterndescription
DecoratorAdd new functionality to objects or classes without changing its structure
ProxyCreates a proxy object to represent a root object and allows the user to interact with the proxy object instead of directly interacting with the original object.
AdapterResolves interface incompatibility between objects
FacadeCreate a simple interface for users to interact with the system

Behavioral Patterns

Focus on how objects and layers interact

Patterndescription
StrategyDefine a series of algorithms and encapsulate them into separate objects, algorithms that can be dynamically changed at runtime
ObserverDefine a 1-to-many dependency between objects, when an object changes state, all dependent objects will be notified and updated automatically
Null ObjectThis pattern provides an empty object or default value to represent an object that does not exist or is not available
MediatorCreate an intermediate object to reduce dependencies between different objects and manage their interactions

End

In the field of Information Technology, we always face common problems. Instead of having to spend a lot of time and effort to solve it on our own, we should learn and use the existing foundations to develop better solutions.

The journey to discover the Design Pattern has only just begun, this introduction is mainly theoretical, how to apply it to the project is the problem. Come with me to the following sections to see how I apply it to real projects. Thank you for reading

Share the news now

Source : Viblo