Basic object-oriented principles and design patterns

Source: Internet
Author: User

The design principle is a guiding and abstract concept. The design mode is a good practical experience to achieve the design principles.

 

After a while of object-oriented programming. The first thing to learn is the design model. The purpose of the design pattern is to make the code clearer, readable, understandable, reusable, extensible, and maintained.

It brings many benefits, and the price may be a few more lines of code. Compared with the above advantages, this price is negligible.

 

In my opinion. In fact, there is no fixed design pattern. The design pattern is just a good implementation or experience summary of the basic object-oriented principles,This experience can be summarized in a variety of ways.(Of course, this kind of implementation will also have flaws, and it will have advantages and disadvantages ). People who have not even learned the design pattern may have used the design pattern, but it is just unconscious. This kind of practice will not happen frequently.

 

 

Following the design principles can make our software more flexible and robust. But flexibility requires a price. The performance loss caused by polymorphism is the most obvious problem. Therefore, we need to make a balance between flexibility and performance.


The reason why we use these principles is to meet the needs of changes, so demand analysis is particularly important. However, no matter how full the demand analysis is, demand changes may occur, so predicting changes becomes a headache. Let's take a look at how agile design (XP) solves these problems: "agile developers will not apply those principles and patterns to a large pre-design. On the contrary, these principles and patterns are applied in iterations to keep the code and code expressions clean. "That is to say, agile design stimulates changes through rapid iterations, exposing these changes as soon as possible, and then making corresponding changes based on the changes. Obviously, this is much easier than a one-time, complete design.


All the art of software development is trade-offs: trade-offs between simplicity and complexity, and trade-offs between one solution and the other. If you take into account every question and every trade-off, I am afraid the cost of developing an application will be astonishing. Therefore, we often rely on our own aesthetic vision to design a pleasing system with a calm mind.

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.