Introduction to the specific application of design patterns in Java

Source: Internet
Author: User

Http://35java.com/zhibo/forum.php? MoD = viewthread & tid = 255 & extra = Page % 3d3

 

I have been reading the book design patterns: Elements of reusable object-oriented software recently. I don't know if anyone who has read this book can't find a clue or can't get started. OK, like me/hand. the 23 modes described in the book often confuse me. It is hard to understand this book without reading it three or four times or more, and even if I read it several times, it is also difficult to grasp the essence. The examples described in this section are c ++ and smalltalk oo languages. I am not familiar with C ++, but it is difficult to explain the examples.
Well, the principle I read is that if I don't understand it, I will read it again in a short time. I have never heard of "have you come again. (In addition, I have never caught a cold in a book. I often see books that share the same kind of knowledge. For the design model-the Chinese version seems to have only one such copy, there are some e-files .) I have read the design patterns several times and have a certain understanding of the structure and content of the design pattern, so I should use actual examples to help me understand the design patterns. If you go back and read a book again, there will be a lot of questions, the feeling of another village. (Not even applause)
In Java, the design patterns is everywhere. JDK is a typical application of the design pattern. The commonly used AWT includes abstractfactory, composite, bridge, strategy, command, Singleton, and so on. I will not elaborate on it. If you are interested, you can study it on your own, hope to send me a piece of experience, false@263.net, I will cry grateful ...... ^ _-, Fan Shi, Wu Shi self-degree. Learning and improving together. Here we will introduce several Java books on design patterns. If you are interested in the design patterns Java companion and thinking in patterns with Java, you can find them. E-wen's. (false: Don't worry, don't you see me brewing emotions? You don't see the water of the Yellow River, don't come back when you rush to the sea, Bodhi has no trees, mirror platform is not clear)
Instance profiling
Java is a huge system. It has a wide range of applications, such as applet, application, JSP/Servet, EJB, RMI, CORBA, and embedded Java. Many people now learn Java from JSP. Unlike in, it started with Applet and application. At present, many people simply learn JSP to learn JSP. The basis of Java is very thin, unfortunately. To help you understand the design pattern and understand the application of design patterns in JSP/servlet, we can extend it to Java. Here we use jive as an example. Jive is a forum Based on JSP/Servlet technology and is an open source software product. Download http://www.coolservlets.com/jive. I don't need to say much about its excellence. Anyone who uses JSP/servlet for development knows. Many people rely on research to get started. Note: This article does not explain JSP/servlet syntax, specific implementation and programming skills. If you need this, I'm afraid I will disappoint you. Please go to Google to search. Here, we mainly use jive to parse thinking in design patterns for Java. This includes Object creation, structure combinations between objects, and object behavior. It involves many OOP concepts, such as classes, objects, inheritance, interfaces, abstraction, encapsulation, and so on. If you are not familiar with OOP and Java, read thinking in Java.
It is also possible that the content I wrote will involve the content of UML. You may be blessed now. Because of my poor level, what can I say about these modes, now the whole society is compiling stories and telling stories ...... If I write something wrong, you should read a story. :) you may also have to talk about it.
Category
The 23 modes are divided into three categories based on the purpose of the model: creational, structural and behavioral modes.
Creational: The creation mode is used to create objects. We often need to instantiate classes in coding. The creation mode is to provide various solutions from Code To make the encoding more flexible and general, suitable for more complex behaviors. · Factory method · Abstract Factory method · builder pattern · prototype pattern · Singleton pattern (Structural)
The structure mode processes the combination of classes or objects to obtain a larger structure. · Adapter pattern · composite pattern, · proxy pattern, · flyweight pattern, · fa çade pattern, · Bridge pattern, · decorator pattern, behavior type (behavioral)
How to interact with a behavior mode processing class or object · Observer Pattern · mediator · memento · chain of responsibility · template pattern · interpreter in a program. · strategy pattern · Visitor pattern · state pattern · Command pattern · iterator Pattern
Design patterns for the kernel of jive
Analyzing jive is not an easy task. It involves many OOP tasks, so it is best to use tools. To do things well, you must first sharpen your weapon. Well, I use Rational Rose because Rose implements UML and can reflect the design ideas and various types, interfaces, objects, and relationships. I want to see through the combination of class diagrams and code, this will be better than simply looking at the code effect. (You can also use JBuilder or J ++, which is convenient to manage. I use the modeling tool rose) Here I use a function of Rational Rose-Java Reverse Transfer Engineering (I think this function and the function of generating Java code has greatly improved for me, whether you master Java or UML & Rose) first, you need to import JDK to Rose. select Tools> JAVA => reverse engineer Java to open the reverse engineer Java window, and select the Servlet Source code we need in jive to generate a reverse model. Of course, you need to set classpath correctly. Many interfaces and abstract classes are used in jive, which are usually used in object-oriented systems.
For code reuse and flexibility, a very important principle of design patterns is interface-oriented programming rather than implementation programming. The second principle is to give priority to object combination, rather than class inheritance. 2.2.1 com. coolservlets. Forum package contains many classes and interfaces. It encapsulates basic forum operations. (What are class and interface? Call ...... If you haven't vomited blood, check the information .) Whether using CGI, ASP, PHP, or even JSP/servlet, I believe many people have done BBS either big or small, simple or complex.
We recommend that you see how jive is designed and implemented. Everyone looks at the problem differently. No matter which angle you choose, I believe you will get nutrition from it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.