Learning the importance of GOF design patterns

xiaoxiao2021-03-06  71

The top expert Richard Monson-Haefel in the famous EJB field is in its personal website: Www.ejbnow.com's "design mode", the original text is as follows:

Design Patterns Most developers claim to experience an epiphany reading this book. If you've never read the Design Patterns book then you have suffered a very serious gap in your programming education that should be remedied immediately.

Translation: Many programmers have finished reading this book, announced that they are equivalent to "main display" (commemorating the birthday and double festival), if you have never read this book, you will be in yours There is a serious crack in the program education career, so you should save it immediately!

It can be said that the GOF design pattern is a compulsory course that the programmer truly masters the object-oriented core idea. Although you may have passed Sun's a lot of dazzling technical certification, but if you don't learn to master the GOF design mode, you can only explain you still a mechanic.

When browsing "Thingking In Java" (first edition), do you think this is still a Java basic language book? However, it is not purely, because the author of this book will integrate object-oriented ideas in Java's specific technologies, and the subtlement makes you feel a new language and new ideas.

But after reading this book, your idea of ​​these things may need a more clear and more comprehensive understanding and master, then you need to study the "design model" of GOF.

"Thingking in Java" is described in this description of the design mode: he is defined in a book in the "Design Patterns" book built by Gang Of Four, abbreviation GOF, is defined in the book. "milestone". In fact, the book has now become a reference book for almost all OOP (object-oriented programming) programmers. (So ​​abroad).

GOF's Design Mode is the basis of all object-oriented languages ​​(C Java C #), but only different languages ​​will be more conveniently used.

The GOF design mode is a "bridge" on the Java language system, GOF design mode is a "bridge" in the Java basics and J2EE framework knowledge.

There are more and more people in Java, but the programmers who have always been in the language level are not in a small number. It is not a lot of applications in Java interface or abstract classes. Everyone often uses those technologies that are only suitable for large projects, avoid or ignore They, in practice, Java interface or abstraction is the core of truly embodying Java ideas, which you will experience them in GOF design models to the infinite magic.

The GOF design mode surface seems to be a specific "technology", and the new design pattern is constantly appearing, the design pattern has its own development track, and these seems to have no techniques such as J2EE .NET!

In fact, GOF design model is not a specific "technology". It tells ideas. It not only shows the flexible apps and wisdom of interface or abstract classes in practical cases, so you can truly master interface or abstract classes. Application, thus leaping in the original Java language, more importantly, GOF design model repeatedly emphasizes a purpose: let your program reuse it as much as possible.

This is actually to a limit challenge: software demand is infinite, the plan is not changed fast, but we still have to look for something, and divide it and change the things, this requires very wisdom and experience.

The GOF design pattern is a milestone that begins to explore in this respect. J2EE, etc. belongs to a framework software, what is framework software? It is different from the Java API we have in contact with the Toolkist, which is no longer being used, called, but a deep intervention into a field, J2EE and other frame software design is The unchanged thing in a field is defined first, such as the overall structure and some main responsibilities (such as database operational transaction tracking security, etc.), the remaining thing is something that changes in this field, and the specific variation needs of specific applications in this field. These changes are what J2EE programmers do.

It can be seen that the design model and J2EE are in the ideological and motivation, but only

1. Design mode is more abstract, J2EE is a specific product code, we can contact, and design mode generate specific code when applying each application.

2. Design mode is a smaller architecture than the J2EE and other framework software. Many of the specific programs in J2EE are completed by design mode. When you go deep into J2EE's internal code research, this is especially obvious, so if you There is no foundation knowledge of design modes (GOF design mode), you can't understand J2EE quickly. Can you understand J2EE, how can I flexibly?

3.j2ee is just a framework software that is suitable for enterprise computing applications, but GOF design patterns can be used almost any app! Therefore, the design pattern of GOF should be one of the important theoretical foundations of J2EE.

So, the GOF design pattern is a "bridge" in Java basics and J2EE framework knowledge. Why is it implicit?

GOF design mode is a hidden "bridge" because many people did not pay attention to this, they directly learned J2EE, some even ducks, and directly using the specific J2EE software such as WebLogic. Down, I found it, it is very easy to use, but do you really understand J2EE? Is your application in a concrete case extension J2EE idea?

If you can't extend J2EE's thoughts, then you are not a cannon, you realize that J2EE is not suitable for people who are suitable for all occasions, but we need to use J2EE to use the place, then understand J2EE this framework The essence of the software, then you can really flexibly apply Java to solve your problem, even arching your own business frame. (We can't always use someone else to set a good frame, why can't we have our own frame?)

Therefore, first you have to master the design pattern of GOF. Although it is implicit, it is not possible.

About this site "design model"

Java provides a rich API, and there is a powerful database system for underlying support. So our programming seems to become simple "patchwork" and calls similar to building blocks, and some people promote "blue-collar programmers", these are modern The programming technology does not understand.

In the actually reusable object-oriented programming, GOF's "design mode" provides us with a set of accessible object-oriented technology, with refactoring (reconstruction), so few simple duplicate work, plus The refining and object-oriented pureness of Java code (the design mode is the soul of Java), and the programming work will turn into an exciting process that allows you to create a pleasure to create pleasure.

In order to discuss "design mode" with you, I will write down my experience in learning, just want to help more people easily understand the "design pattern" of GOF. Since the original art is C as an example, the design pattern as Java is basically a graphic application as an example, and we are more concerned about the application of Java in server, etc., so all instances of this site are non-graphical applications. And the JIVE forum system is used in the way. At the same time, to reduce the difficulty of understanding, try to avoid using the UML map.

If you have a certain object-oriented programming experience, you will find some of some of the design patterns, you have not used it; if you are a newcomer, then develop your own good program habits (let your program use universal) The mode is easy to understand; let you reduce the programming of repetitiveness), which is undoubtedly a must-have condition for excellent programmers. The entire design pattern runs through a principle: facing interface programming, not facing the implementation. Goal The principle is to reduce coupling and enhance flexibility.

转载请注明原文地址:https://www.9cbs.com/read-93091.html

New Post(0)