Hello friends, design pattern is a very generic term, but in this article, I will try to explain design patterns in software aspects.
Types of Design Patterns
There are two types of Design Patterns.
- Architectural design pattern
- Application/Code Level design patterns
Architectural design pattern
When we think of designing software without having an architectural design, it is very similar to designing or building a home without having any architectural design. The below problems will occur.
- The size of rooms will be random as the contractor will design by himself, and there will be a lot of issues that will happen as you do not have any final design in mind. There will always be a communication gap.
- Construction quality: As you do not have any final design, the contractor will use quality based on his experience.
He will never try to estimate future problems and will try to finish his work ASAP.
- Plumbing issues: when we do not have any plumbing design in the home, the plumber will install pipes, taps, etc. With his experience, he will never think about what exactly you need. When you start living in such type of home, you will find leakages behind walls, low pressure, insufficient water flow, etc.
- Electrical issues: it is again a very important aspect if we do not have the correct electrical design then in future, we may get issues like, for Air conditioning, we need a 4 mm wire point, but the technician installed only 1.5 mm wire, and all wires are inside walls, and then if we start running high load on such things then fire or huge loss may occur.
This is a very common scenario in summer, and we are getting a lot of fire accidents.
- I think the above points are sufficient to explain how much Architectural design matters when we are designing something.
- When we get a request from the customer, then this is the first part we start working on. We start meetings with the client to understand the overall scope and try to document it.
- Suppose the Client is asking for an e-commerce application; then we need to think about each and every aspect.
- E-commerce applications have multiple modules/components like Customer module / Order module / Billing module/ Admin module etc.
- Each module may or may not have its own database. We may need multiple types of databases in our application as per customer requirements.
- When we design an application, we face a lot of issues, and Architectural design patterns help us in various situations and provide problem-specific solutions.
- This is a high-level design for the overall applications workflow. The application will have multiple components and another external dependency.
As we have multiple components, this type of design pattern focuses on the following:
How do individual components communicate with each other?
The customer and order module need to communicate with each other when an order is placed for a customer.
There will be a lot of ways to communicate one module to another module. It depends on client requirements and what exactly the business needs.
How do we apply security to components?
It may be JWT auth or maybe another type of security implementation needed.
- How to make components reusable
- How much actual traffic will be on site, and how much traffic will be in the future if the customer base increases vertically?
- Suppose we have a login module, and then we need to reuse this module in each and every module without any issues. There is no need to create separate Login functions for each at the component level, and when we have to update some features, it will be easy to apply everywhere.
- How to test individual components.
If we do not have proper architectural design, then we may get a lot of issues.
If we have a good design, then individual testing along with integration will be easy for developers and testers.
In this article, I am just trying to cover only high-level aspects. I will share another article with further details.
Popular Architectural design patterns
Application Level Design Pattern
These design patterns are those that apply at the code level. These design patterns are applied to only the code level.
The overall intent of these patterns is.
- how objects will be created
- and how objects will travel from one class to another
- What will be the time of object between request and response?
- How many objects are going to be created as per user request?
- How much memory will these objects consume?
- How can we reuse objects so that the application performs well?
If we reuse the object, then it will take less memory and will have better CPU utilization.
When we have applications and classes, then these design patterns help in the following way.
- We can reuse code in multiple classes: If a proper design pattern is applied, then code will be less maintainable and reusable.
- Testing of code: If we have good written code, code will be easy to test, and then the developer will be able to write good unit test cases
- Code enhancement: If we have a good design at the code level, like if we have interface implementation, then the code will be easy to enhance without modifying already tested code.
Application Design patterns are divided into three categories.
- Creational Design Patterns: Creational design patterns solve the problems related to object creation
- Structural Design Patterns: The structural design patterns suggest implementing relationships between classes and objects.
- Behavioral Design Patterns: The behavioral design patterns suggest ways of communication between classes and objects.
Below is a list of a few application design patterns.