Rereading Design Patterns

I have a bit of time recently, so I looked at the most urgent thing to do, and I checked it turned out to be rereading the design pattern. In fact, I don’t know how many times I have read it. Of course, every time I read it, I have a different understanding. The feeling of epiphany! ? This feeling is much stronger than before.

Solved multiple problems, such as: overuse of design patterns, why overuse? How can you tell if you are overusing design patterns?
I summed up the criteria for over-judging: we only use design patterns for one original purpose, that is, simplicity and convenience. But when we look at the pattern, we find that it is very troublesome. The left inherits the right reference. In fact, one thing it is doing is to realize the first theorem OCP (Open-Closed Principle) in OOD, and of course there are designs for fixed pattern applications. Patterns that have little to do with OCP, such as Singleton, are mainly used to: ensure that a class has only one instance and provide a global access point to access it. These modes are applied in a single way, and they are often mastered at the first contact, so they are also the best ones to apply. Those complicated patterns are for OCP, and OCP is to make your code easy to maintain, so a good program, applying design patterns, is to make the program easy to maintain in the later stage. Complex patterns need to be judged based on business and system analysis, which is difficult to control. Therefore, improper application will make the program not only easy to maintain, but also make maintenance more difficult.
Why is it overused? It's because we didn't consider OCP when coding, but directly used the result of the pattern. Specifically based on what pattern is overused, I haven't fully figured this out yet. But if we ask ourselves if we are using patterns without thinking in connection with OCP, it should be over-using patterns.
How can you tell if you are overusing design patterns? Of course, if OCP is considered, using design patterns according to the principles of Open is the correct use. Of course, this use process is a design process, there are skilled and unskilled, correct and incorrect use, this needs to be verified by practice.

This is a little bit of my recent reading experience, I hope the Illuminati will make a brick, huh, huh

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326938735&siteId=291194637