Design pattern family - iterator pattern, adapter pattern
Iterator mode
brief introduction
The so-called Iterator mode is the interface programming for Iterator. No matter how the underlying data structure and iterative algorithm change, the caller does not need to modify the code;
High cohesion and low coupling are the way of programming.
Generally, you rarely need to write this iterator mode you ...
Posted by pup200 on Sun, 02 Jan 2022 07:21:28 +0100
java Decorator Pattern
1, Decorator mode definition 1. Dynamically add some additional responsibilities to an object. In terms of adding functions, decoration pattern is more flexible than generating subclasses Component abstract component Component is an interface or abstract class, which is to define our core objects, that is, the most primitive objects. Defining ...
Posted by gateway69 on Sat, 01 Jan 2022 22:53:24 +0100
Design pattern principle
Design pattern
reference resources:
[1]: http://c.biancheng.net/view/1322.html "" C language Chinese network ""
[2]: https://www.bilibili.com/video/BV1Np4y1z7BU
Design principles
Opening and closing principle
Open for extension and close for modification. The code can be extended and cannot be modified
Interfaces and ...
Posted by goldenei on Sat, 01 Jan 2022 16:29:45 +0100
Combination mode of design mode
In real life, there are many "part whole" relationships, such as departments and colleges in universities, departments and branches in head offices, books and schoolbags in school supplies, clothes and wardrobes in daily necessities, pots and pans in kitchens, etc. The same is true in software development, such as files and folders in ...
Posted by watts on Sat, 01 Jan 2022 08:44:14 +0100
Factory pattern - abstract factory pattern
1. Abstract factory mode
To solve the problem that the factory method pattern cannot create a group of related or interdependent objects, the abstract factory pattern is introducedOfficial definition of abstract factory pattern
It is a pattern structure that provides an interface for the access class to create a group of related or int ...
Posted by CashBuggers on Fri, 31 Dec 2021 21:54:41 +0100
Builder mode - creative - Design Mode
Specific needs
Demand for building a house:
Need to build a house: this process is piling, building walls and cappingThere are all kinds of houses, such as ordinary houses, high-rise buildings, villas. Although the process of all kinds of houses is the same, the requirements are different.
Traditional ways to solve problems: Analysis of ...
Posted by seavolvox on Fri, 31 Dec 2021 13:45:15 +0100
The beauty of design patterns iterator pattern: what are the advantages of using iterators over directly traversing set data?
The beauty of design patterns by Wang Zheng Study notes
Principle and implementation of iterator pattern
Iterator Design Pattern, also known as Cursor Design Pattern.Iterators are used to traverse containers, so a complete iterator pattern generally involves containers And container iterators.
Implement an iterator
Suppose that linear data ...
Posted by vexusdev on Fri, 31 Dec 2021 08:37:39 +0100
[design pattern] behavioral pattern Interpreter pattern
preface
I suggest reading this article first [design mode] 7 principles of software design and 23 design modes (I)
I Interpreter mode
Interpreter pattern is used to construct a simple language interpreter to interpret and execute strings in a custom way. It is an uncommon design pattern
Unless you are engaged in low-level development an ...
Posted by rob.weaver on Fri, 31 Dec 2021 03:08:30 +0100
Design pattern - observer pattern
preface
This paper briefly introduces a kind of design pattern, observer pattern
(previous article) design pattern - Decorator Pattern_ Autumn rain - CSDN blog
catalogue
1, Definition and characteristics of observer model
2, Structure of observer model
3, Code example
1, Definition and characteristics of observer model
Definit ...
Posted by chimp1950 on Thu, 30 Dec 2021 12:22:53 +0100
21 basic introduction of intermediary model
1. Basic introduction
1) Mediator Pattern, which encapsulates a series of object interactions with a mediation object, makes each object do not need to be explicitly introduced into each other, so that it is loosely coupled and can be used
Change their interaction independently
2) The mediator pattern is a behavioral pattern that makes the c ...
Posted by Danno13 on Thu, 30 Dec 2021 06:03:09 +0100