Powered by http://www.wufuheng.com/
Telling Oo, people who have learned for a few years will say, oo, I will. Java is born is OO, I have been using Java, I naturally oo. When OO is simple, there are several Class. But when complicated, one person wrote several CLASS to complete a project, and another person also wrote a few Class, but Reusability, Flexibility is out of stock. To make a simple example, you have to make a Window, there is button, scroll bar, status bar, etc., this Window is supported in different forms, such as Bitmap_Window, these button, scroll bar, status bar can be drawn on Load Good picture, better look. For example, Plain_Window is all ordinary Button, Scroll Bar, Status Bar. How will you design? Very simple. base class: buttonderived class: bitmap_button, plain_button etc. base class: scroll_barderived classbitmap_scroll_bar, plain_scroll_bar this design looks really good, you want to create a window, so you can window mainwin = new bitmap_windowbutton button1 = new bitmap_buttonbutton button2 = new bitmap_buttonmainwin.add ( Button1) mainwin.add (button2) scroll_bar sbar = new bitmap_scroll_barmainwin.add (sbar) You may say that this is not very good, but if I want to turn the entire window into plain? Turn the entire window into other forms? Search and Replace, replace all Bitmap to Plain. Window mainwin = new plain_windowbutton button1 = new plain_button, etc. Maybe you don't have any trouble, but if it is a big project, Button and so on must be created everywhere, and it is very troublesome to modify it. It is easy to make mistakes. This is involved in Flexibility.
Is there a good solution? Have! The design patterns abstract factory.abstract class BaseFactory {abstract public window createWindow (); abstract public button createButton (); abstract public scroll_bar createScrollBar (); // etc etc} class BitmapFactory: BaseFactory {public window createWindow {return new bitmap_window;} public button createButton {return new bitmap_button;} public scroll_bar createScrollbar {return new bitmap_s_bar;}} class PlainFactory: BaseFactory {public window createWindow {return new plain_window;} public button createButton {return new plain_button;} public scroll_bar createScrollbar {return new plain_s_bar; }} You may ask, what is the use of these things? Have! BaseFactory factory = new BitmapFactory; window mainWin = factory.createWindow (); button button1 = factory.createButton (); button button2 = factory.createButton (); window.add (button1); window.add (button2); if you want to Change to Plain, only the basefactory factory = new placefactory is OK! The benefits of doing this are obvious. First, users don't need to care about BitmapWindow, PlainWindow, or what Window, Object Creation, and concrete Code are completely separated, which greatly reduces Dependcent. Second, this enforce is Bitmap_Button only can be added to Bitmap_window. There is also a range of benefits. I will not repeat. Interested friends, please see this book. Design Patterns (1995 Addison-Wesley). What is this book? I am not good, I don't say much, please see the book review of others. The most important software development book "Design mode" ● "Design mode" "Design mode" in the "Design Patterns: Elements Of Reusable Object-Oriented Software", this book The name of the book has been published in 1995. The book has four authors Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, all Ph.D., one is not small. The book is called a classic name for object-oriented, has been ranking Amazon sales list, and Amazon's readers have achieved a full five stars. Expert scholars have also praised "design patterns". It has been praised: "This book is one of the best, the best, the best, and the book is not a general, but a combination of examples, in the best way. The legal status of the model is established.
"- Stan Lippman, C Report" This public looks forward to achieving full effects. The book gathers the available design of time test. From the years of object-oriented design experience, the author selected 23 models, which constitutes the essence of the book, and every excellent programmer must have this "design mode". "--Larry O'Brien, Software Development"
This book is not reading the high school. Only if there is a considerable basic reader to benefit from this book, readers must first become familiar with object-oriented design languages such as C or Java, and it is best to develop and maintain object-oriented software. Only some of the design experiences can fully understand the design model. Although the publication of this book is late for nearly five years than in the English version, it always has a huge progress. According to reliable news, there are several publishers in China to introduce foreign technical names. It keeps tracking abroad to track foreign technology in technology publishing. This is the best in the overall level of domestic software industry, and the latest software. Technology and development comes from abroad, I hope that the future technical name is no longer the difference in these five years, and I hope that my country's software industry will go overseas. -------------------------------------------------- ---------------
http://www.wufuheng.com/