[design mode] overview


Seeing the 30 days of the Nuggets posting more challenges, I want to try my best to stick to it for a few consecutive days. The prize is not important. Does it focus on participation?
In the next 30 days, I will lead you to learn design patterns. In the past, I always felt that design patterns were very complex and rarely used in general routine programming. After careful reading, I found how ignorant my previous ideas were. If a programmer wants to improve himself and make himself more valuable, the technical knowledge points of code specification and design pattern also need to be understood and mastered.

In fact, in daily development, we will use design patterns more or less, but we are not very clear. For example, we often use singleton mode, factory mode, etc.

The landlord is mainly engaged in C # development, and the code exemplified in the program uses C #.

Overview of design patterns

(abstraction, encapsulation, inheritance, polymorphism) is the basic concept of object-oriented (OO). OO principle is our goal, and design pattern is our practice.

There are 23 design patterns in total, which can be divided into three categories from the perspective of large structure, namely, creation pattern, structure pattern and behavior pattern.

Create pattern

This kind of pattern is a mechanism for creating objects, which can improve the flexibility and usability of existing code.

  • Factory method
  • Abstract factory
  • generator
  • prototype
  • Single case

    Structural model

    This paper introduces how to assemble objects and classes into a larger structure while maintaining the flexibility and efficiency of the structure.

  • Adapter
  • bridging
  • combination
  • decorate
  • appearance
  • Enjoy yuan
  • agent

    Behavior pattern

    Such models are responsible for efficient communication and responsibility delegation between objects.

  • Chain of responsibility
  • command
  • iterator
  • tertium quid
  • memorandum
  • Observer
  • state
  • strategy
  • template method
  • visitor

    If you only have a hammer, everything looks like a nail. Then we should strive to have multiple hammers in our hands.

The most basic, underlying patterns are often referred to as idioms, which can only be used in one programming language.

The most common and high-level pattern is architecture pattern. We can use this kind of pattern in any programming language. Unlike other patterns, they can be used for the architecture design of the whole application.

Small message

A person’s struggle, like pregnancy, will always be seen after a long time.

Life is short. I don’t want to pursue what I can’t see. I just want to catch what I can see.

I amSay, thank you for reading. If it helps you, please like it and forward it. Thank you.

Recommended Today

Dynamic expansion of SCST shared disk

SCST shared disks support online capacity expansion. The operation is as follows: SCST server First, there is a ZFS storage volume, and now its capacity is expanded from 15g to 20g. zfs set volsize=20G tank/vol Modify the size attribute of device in SCST scstadmin -set_dev_attr device1 -attributes size=21474836480 -noprompt ISCSI client Rescan target iscsiadm -m […]