Basic Design Patterns

Source: Internet
Author: User

Good System Design pursues the following features:

L extensibility: new functions or features can be easily added to the system;

L flexibility: allows code modifications to take place smoothly without affecting many other modules;

L pluggability: You can easily extract a class or component and add another class/interface with the same interface.

Systems with the above features have real maintainability and reusability. Maintainability and reusability

It is vital for large software products that require continuous access, gradually improve existing functions, and enrich new functions, and whose versions will not be terminated.

Traditional reuse includes code copy reuse, algorithm reuse, and data structure reuse.

In the Object-Oriented field, data abstraction, encapsulation, inheritance, and polymorphism are the most important language features. These features allow a system to provide reusability at a higher level. Abstract and inheritance relationships of data allow reuse of concepts and definitions; polymorphism allows reuse of implementations and applications; abstraction and encapsulation can maintain and promote the maintainability of the system. In this way, the focus of reuse is no longer on specific implementation details such as functions and algorithms, but on the abstract layers of the most important macro business logic. The reversal of reuse focus is not because the reuse of Implementation Details is no longer important, but because the reuse of these details is often done well (for example, it is easy to find and apply mature Data Structure class libraries, etc. What really impacts the system is the ever-changing business needs to be implemented.

In essence, if the demand for a software never changes or develops, the software does not need any design, and how to implement code can be done. As long as the demand is met, the performance is up to standard. But in fact, the nature of software is constantly increasing, expanding, and changing. We can control every line of code flowing at our fingertips, but we cannot control the needs of users serving as God. The code is complete and all tests are passed. During the trial, the user finds that there is a problem with the original requirements and needs to change or propose new requirements. What should I do? Protest to users: demand is always changing and cannot be done !? In my mind, I complained that I had to work overtime to modify a lot of code, and the crazy test was still time-consuming? Or is it easy to understand: This change or small demand is reasonable, and the system is very convenient to be included; so we can negotiate with the user about the next delivery time?

To make the system adapt to the change or addition of demand to the greatest extent, efforts must be made to abstract reuse of the macro business logic to be implemented. The design mode is to extract and summarize common methods and experiences that use object-oriented technologies and features to improve the reusability of business logic.

The key to understanding the 23 design patterns is to understand their common purpose: to make the software system designed in general or specific (the system may expand at specific points in the future) scenarios, open the extension as much as possible and disable the modification. That is, in the face of new requirements or requirements changes, it is easy to develop new code independent of existing code to access the existing system or make a few controllable changes to the existing code, instead of adding, deleting, and modifying a lot of existing code. For this purpose, the 23 design patterns run through the basic principles of object-oriented programming:

L Interface-oriented or abstract programming, rather than implementation programming.

L an object should have as little understanding as possible about other objects, that is, loose coupling.

L when purely functional reuse, do not use inheritance, but use a combination. Make existing objects part of new objects. New objects reuse existing functions by assigning them.

 

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.