On Design Patterns

On Design Patterns

Design patterns are a way to solve common problems in software design. There are over 20 design patterns, but only a few are commonly used. It is important to know these patterns well because they can help you write more modular, reusable, and maintainable code.

Design patterns can be divided into three main types: creational, structural, and behavioral.

??. ???????????????????? ????????????????

Creational patterns deal with object creation. They provide a way to create objects in a flexible and extensible way. Important patterns in this group are:

????????????????: The Factory pattern is a way to create objects without exposing the instantiation logic to the client. This can be useful when you want to create different types of objects depending on the situation.

????????????????????: The Singleton pattern ensures that a class has only one instance. This can be useful when you need to coordinate actions across the system or when you want to ensure that there is only one copy of a resource.


??. ???????????????????? ????????????????

Structural patterns deal with the composition of objects. They provide a way to combine objects to create larger structures. Important patterns in this group are:

????????????????: The Adapter pattern is a way to make two incompatible interfaces work together. It does this by wrapping an existing class with a new interface that is compatible with the client's interface. This can be useful when you need to use an existing class that does not have the interface you need.

??????????????: The Fa?ade pattern is a way to simplify a complex subsystem. It does this by providing a single interface that hides the complexity of the subsystem from the client. This can be useful when you need to make a subsystem easier to use.

????????????????????: The Decorator pattern is a way to add new functionality to an object without modifying the object's code. It does this by wrapping the object with a decorator class that adds the new functionality. This can be useful when you need to add new functionality to an object dynamically.

????????????: The Proxy pattern is a way to control access to an object. It does this by creating a proxy object that stands in for the real object. The proxy object can then be used to control access to the real object. This can be useful when you need to protect the real object from unauthorized access.


??. ???????????????????? ????????????????

Behavioral patterns deal with the communication between objects. They provide a way to define how objects interact with each other. Important patterns in this group are:

????????????????: The Command pattern is a way to encapsulate a request as an object. This allows you to treat the request as data and pass it around your system. It can also be used to queue requests or to undo requests.

?????????????????? ????????????: The Template Method pattern is a way to define the skeleton of an algorithm in a method. This method can then be overridden by subclasses to provide different implementations of the algorithm. This can be useful when you want to keep the overall structure of an algorithm the same but allow different implementations of the algorithm.

??????????????????: The Strategy pattern is a way to encapsulate a family of algorithms. This allows you to choose the algorithm that is most appropriate for the current situation. It can also be used to make your code more flexible and extensible.

??????????????????: The Observer pattern is a way to define a one-to-many dependency between objects. This means that when one object changes state, all of its dependents are notified and updated automatically. This can be useful when you want to keep track of changes to objects in your system.

Anish Cheriyan, PhD

Vice President Test (Intelligent Cockpit), Harman Automotive, IEEE Sr. Member, Author

1 年

Arvind Saraswat you explained the creational, structural and behavioural design pattern in very clear manner. Great job

要查看或添加评论,请登录

Arvind Saraswat的更多文章

  • Career truths we all will realize, sooner or later

    Career truths we all will realize, sooner or later

    1. Everyone is self-interested, but not everyone is selfish.

    6 条评论
  • Statistics and Life Lessons

    Statistics and Life Lessons

    Some Life lessons that have origins in Statistics. 1.

    1 条评论
  • A brief history of Quantum computers

    A brief history of Quantum computers

    1905: Albert Einstein explains the photoelectric effect and suggests that light consists of quantum particles or…

    1 条评论
  • Don’t be Ned Ludd.

    Don’t be Ned Ludd.

    We Are All Ned Ludd Now. The fear of AI is quite similar to the Story of Ned Ludd.

  • Best Leadership Traits

    Best Leadership Traits

    Leadership traits are the personal qualities that shape effective leaders. Many leadership traits are transferrable…

  • Pigeonhole principle

    Pigeonhole principle

    Simply put, the principle states that if you have N pigeons and M pigeon holes, where N is greater than M, at least one…

  • On Behavioral Economics and Consumer psychology

    On Behavioral Economics and Consumer psychology

    I recently completed a reading on Behavioral Economics and Consumer psychology. A recap of important theories that I…

    1 条评论
  • Conway’s Law

    Conway’s Law

    Conway's law is an adage that states organizations design systems that mirror their own communication structure. It is…

  • On being Happy...

    On being Happy...

    The Grant Study is part of the Study of Adult Development at Harvard Medical School. It is a 75-year longitudinal study…

  • Because you only ever deserved a Styrofoam cup.

    Because you only ever deserved a Styrofoam cup.

    From the book - Leaders Eat Last: Why Some Teams Pull Together and Others Don't I heard a story about a former Under…

社区洞察

其他会员也浏览了