Rethinking the design pattern in the reconstruction

Source: Internet
Author: User

What is design mode?


each type of programming language has its own characteristics, like an object-oriented language, characterized by encapsulation, inheritance, polymorphism, abstraction. At the same time, there are some design guidelines for developing software in each type of programming language, which guarantees the quality of the software, which is a good design.


The design pattern is the development experience of the software developers, they use the characteristics of programming language to achieve these guidelines. Therefore, to be able to imagine, when we are familiar with the design pattern to a certain extent, when designing the system. Our eyes will become no design patterns, only the design guidelines, really reach the hands without swords. The position of a sword in my heart.


while learning to design patterns. What are you going to learn?


ever . At the beginning of this stage of learning, there are children shoes asked me. So many things.  What are you going to learn? Learn what. And see what this thing is for . Of course, the main learning of this model mainly overcomes what problems.


In the Book of design patterns, we will see a section called "intent". What is the intention? Over here. This intention answered for example the following questions:

1. What is the design pattern?

2, what is its rationale and intentions?

3, what is it that solves a particular design problem?

But the intent of many design patterns does not explain the main problem of pattern resolution. A lot of other descriptive narrative patterns are what to do and how to use them.


Why should we focus on understanding what problems the design pattern overcomes? Because patterns exist to solve this problem, it's important to understand whether patterns are really helpful in some situations, and what they can help solve.


Second, learning is how it solves this problem. But a lot of people come up and expect to be putting the cart before the horse to learn how it solves the problem. Ignoring the simplest and most important things.


What are the problems with easy in app design mode?


watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvbghjmtewnq==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">

After learning the design pattern. As a person who has just started learning, Easy appears two questions:


1 , over-design: the flexibility and complexity of the code exceeds what is required.

Some program apes do this because they believe they know what the future needs. They judged that the design was designed today to be more flexible to suit tomorrow's needs. But assuming an estimate is wrong, it's a huge waste. caused the "use of artillery to hit the mosquitoes" dilemma.

Agile development principles tell us not to add a push-based approach to code. The actual function is not necessary, if it is unclear whether a system needs a certain mode, generally do not rush to achieve it. In fact. It is not difficult to reconstruct the pattern when needed.

(selected from "Big Talk design Mode")

2 . The problem of inadequate design: this is much more common than over-design.

For example, in the first time to do the computer room charging system, we re-implement the function, and ignore the overall structure of the system, assuming that a real software use such a method, then, after the system delivery, operations will become extremely difficult. When the software becomes a big mud ball, we can just try to refactor and start over again.


How to use design patterns properly?


Using the model to improve the existing design is better than the early use of the design model, through the evolution of the design rather than using large-scale pre-design, through refactoring. Trend and removal mode. Instead of designing early usage patterns. Delays in the use of patterns have avoided the problem of over-design, and have also considered the design deficiencies in the system.

By gradually improving the design of the code, the line gradually sniffed out the bad taste of the code and found out where there was a problem. The improvement of the design is the most successful.





--a reference to "big Talk design Mode" & "Reconstruction and Model"








Rethinking design Patterns in refactoring

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.