What is design pattern?

yoon jong·2022년 5월 14일
0

Goal

  • The reason why we need to use design pattern
  • Classification of design patterns
  • Specific useage of design patterns

The reason why we need to use design pattern

The usefulness of using a design pattern is obvious. The design pattern can accelerate the development process. It provides proven development paradigms, which helps save time without having to reinvent patterns every time a problem arises.

Because the design pattern is created to fix known problems, they can be predicted before they become visible during the implementation process. Again, the design pattern speeds up the development process. Standardization related to the design pattern is also very useful to facilitate code readability.

In short, the design pattern is useful when moving from an analysis model to a development model. It can be used in a concrete way in several cases, in particular for managing the payroll system when changing a salary and keeping the system informed of the changes this implies.

Thanks to the design pattern, it is possible to document the solutions to be adopted based on previous practices and lessons learned. Several software components are used in the implementation of the design pattern. The model therefore speeds up a process that involves several components. Developers use the language they are familiar with in the application of each solution.
refer to ::Design pattern: what is it and why use it?


Classification of design patterns


Design Patterns are categorized mainly into three categories: Creational Design Pattern, Structural Design Pattern, and Behavioral Design Pattern. These are differed from each other on the basis of their level of detail, complexity, and scale of applicability to the entire system being design.

There are also two types of patterns - idioms and architectural patterns. But we will not explore them in this tutorial.

1. Creational Design Pattern

As the name suggests, it provides the object or classes creation mechanism that enhance the flexibilities and reusability of the existing code. They reduce the dependency and controlling how the use interaction with our class so we wouldn't deal with the complex construction. Below are the various design pattern of creational design pattern

  • Abstract Factory- It allows us to create objects without specifying their concrete type.

  • Builder - It is used to create the complex objects.

  • Factory Method - It allows us to create object without specifying the exact class to create.

  • Prototype - It is used to create a new object from the existing object.

  • Singleton - Singleton design pattern
    make sure that there is only one instance of an object is created

2. Structural Design Patterns

Structural Design Patterns mainly responsible for assemble object and classes into a larger structure making sure that these structure should be flexible and efficient. They are very essential for enhancing readability and maintainability of the code. It also ensure that functionalities are properly separated, encapsulated. It reduces the minimal interface between interdependent things.

  • Adapter - It provides us for two incompatible classes to work together by wrapping an interface around one of the existing classes.

  • Composite - It wraps a group of objects into a single object.

  • Bridge - It decouples an abstraction so that two classes can vary independently.

  • Decorator - It extends the object behavior dynamically at the run time.

  • Facade - It offers a simple interface to more complex underlying objects.

  • Flyweight - It decreases the cost of complex object model.

  • Proxy - It reduces the cost, reduce complexity, and provide the placeholder interface to an underlying object to control access.

3. Behavior Design Pattern

Behavior Design Patterns are responsible for how one class communicates with others.

  • Chain of Responsibility - It representatives the command to a chain of processing object.

  • Command - It generates the objects which encapsulate actions of parameters.

  • Interpreter - It implements a specialized language.

  • Iterator - It accesses all the element of an object sequentially without violating its underlying representation.

  • Mediator - It provides the loose coupling between classes by being the only class that has detailed knowledge of their existing methods.

  • Memento - It restores an object in the previous state.

  • Observer - It allows a number of observer objects to see an event.

  • State - It allows an object to modify its behavior when it's internal states changes.

  • Strategy - It provides one of the families of algorithm to be selected at the runtime.

  • Template Method - It allows the subclasses to provide concrete behavior. It also defines the skeleton of an algorithm as an abstract class.

  • Visitor - It separates an algorithm from an object structure by moving the hierarchy of methods into one object.

refer to ::think your task, choose your design patterns

Specific useage of design patterns

todo:: Upcoming contents will be specific examples of design patterns in flutter. Catch u later.

profile
code runner

2개의 댓글

comment-user-thumbnail
2023년 4월 6일

who need help improving their coding skills butterfly locs, daily game solve cross

답글 달기
comment-user-thumbnail
2023년 4월 30일

ElishaSchappell credible login

답글 달기