What is design pattern

  • What is

In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn’t a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.

Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Patterns that imply mutable state may be unsuited for functional programming languages. Some patterns can be rendered unnecessary in languages that have built-in support for solving the problem they are trying to solve, and object-oriented patterns are not necessarily suitable for non-object-oriented languages.

Design patterns may be viewed as a structured approach to computer programming intermediate between the levels of a programming paradigm and a concrete algorithm.

  • Creational design patterns
NameCategoryDescriptionRemark
Abstract FactoryCreationalCreates an instance of several families of classes-
BuilderCreationalSeparates object construction from its representation-
Factory MethodCreationalCreates an instance of several derived classes-
Object PoolCreationalAvoid expensive acquisition and release of resources by recycling objects that are no longer in use-
PrototypeCreationalA fully initialized instance to be copied or cloned-
SingletonCreationalA class of which only a single instance can exist-
  • Structural design patterns
NameCategoryDescriptionRemark
AdapterStructuralMatch interfaces of different classes-
BridgeStructuralSeparates object construction from its representation-
CompositeStructuralA tree structure of simple and composite objects-
DecoratorStructuralAdd responsibilities to objects dynamically-
FacadeStructuralA single class that represents an entire subsystem-
FlyweightStructuralA fine-grained instance used for efficient sharing-
Private Class DataStructuralRestricts accessor/mutator access-
ProxyStructuralAn object representing another object-
  • Behavioral design patterns
NameCategoryDescriptionRemark
Chain of responsibilityBehavioralA way of passing a request between a chain of objects-
CommandBehavioralEncapsulate a command request as an object-
InterpreterBehavioralA way to include language elements in a program-
IteratorBehavioralSequentially access the elements of a collection-
MediatorBehavioralDefines simplified communication between classes-
MementoBehavioralCapture and restore an object’s internal state-
Null ObjectBehavioralDesigned to act as a default value of an object-
ObserverBehavioralA way of notifying change to a number of classes-
StateBehavioralAlter an object’s behavior when its state changes-
StrategyBehavioralEncapsulates an algorithm inside a class-
Template methodBehavioralDefer the exact steps of an algorithm to a subclass-
VisitorBehavioralDefines a new operation to a class without change-

Reference

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qwfys200

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值