Author: Knowledge Talk, CSDN Blog Expert, Alibaba Cloud Signed Blogger, InfoQ Signed Blogger, Huawei Cloud Cloud Sharing Expert
Areas of Expertise: Full Stack Engineer, Crawler, ACM Algorithm
Official Account: Knowledge Talk
Summary of Design Patterns and Other Principles
The following is my simple understanding of design patterns and design principles, not to copy and paste things on the Internet, my own brief understanding,
It is more vernacular
, hope that helps.
The main dish is here
Design mode has a total of 23 design modes. In fact, I personally think that design mode is 23 kinds of programming ideas.Maybe you don't know during the coding process, but you are actually using a certain idea to code, just to name a few patterns and applications that you can still remember.
Factory mode: such as our custom object creation object, such as A object is specially used to create B object, that is, A is a factory class.
Abstract factory mode: Our commonly used ApplicationContext, BeanFactory, is the abstract factory mode
Insert a little:The factory pattern specializes in producing the same kind of objects, and the abstract factory pattern produces multiple kinds of objects
Proxy mode: The proxy mode is also a proxy object created to enhance the function of a method.
The difference between the decorator and the proxy mode is that the decorator does not change the original object, and a new target object will be created inside the proxy object created by the proxy mode
Adapter mode: We commonly use FileInputstream, which can only read byte streams by default. In order to adapt to read character streams, use InputStreamReader to transfer theThe incoming FileInputstream creates a reader object.
Flyweight pattern: Flyweight pattern, also known as lightweight pattern, is a label for object pooling.Similar to the thread pool, the thread pool can avoid the constant creation and destruction of objects, which consumes performance.Flyweight pattern can reduce the number of objects. Its purpose is to share fine-grained objects and centralize multiple accesses to the same object.
Seven design principles
Warm reminder: This is a bit too much, please read it carefully
Liskov replacement principle: that is, the subclass can replace the position of the parent class, which means the method of the parent class, which the subclass cannot changeThought.
The above is my simple understanding of design patterns and design principles, not to copy and paste things on the Internet, my own short-answer understanding, I'm more inclined to the vernacular, I hope it helps.