Reflections on Design Patterns in reconstruction

Source: Internet
Author: User
What is the design model?


Each type of programming language has its own characteristics, such as object-oriented language. Its features are encapsulation, inheritance, polymorphism, and abstraction. at the same time, there are some design guidelines when developing software using each type of programming language. These guidelines ensure the quality of the software, that is, they have a good design.


The design patterns are the development experience and skills summarized by the majority of software developers. They use the characteristics of programming languages to implement these principles. therefore, we can imagine that when we are familiar with the design model to a certain extent, when designing the system, we will see that there will be no design patterns, only the design principles, truly reaching hands without a sword, there is a sword in mind.


What should I learn when learning the design model?


In the past, when I started my study at this stage, some children's shoes asked me what to learn with so many things? What to learn depends on what it is used for. Of course, it is mainly to learn what problems this mode has solved.


In the design pattern book, we will see a part named "intent. What is the intention? Here, this intention answers the following questions:

1. What is the design pattern?

2. What is its basic principle and intention?

3. What specific design problems does it solve?

However, the intent of many design patterns does not describe the main problems solved by the pattern. More details about what the pattern is and how to use it.


Why do we need to understand the problems solved by the design model? The reason why a pattern exists is to solve the problem, so to understand whether the pattern is actually helpful in certain situations, you must understand what problems they help solve.


Second, we learned how to solve the problem. However, many people come up with an estimate that they are putting the cart before the horse. They come up to learn how to solve the problem and ignore the simplest and most important thing.


What problems are common in application design patterns?


 

After learning the design model, as a beginner, there are two problems:


1. Over-design: the flexibility and complexity of the Code exceed the requirements.

 

Some programmers do this because they believe they know their future needs. They inferred that the design scheme is more flexible today to meet tomorrow's needs. However, if an error is expected, this is a huge waste. This has led to the dilemma of "using cannons to fight mosquitoes.

 

The agile development principle tells us that we should not add functions that are based on speculation or are not actually needed for the code. If we do not know whether a system needs a certain mode, we should not rush to implement it. In fact, it is not difficult to implement this mode by refactoring as needed. (Selected from "big talk design mode")

 

2. Insufficient design: This is more common than over-design.

For example, when we first set up a data center charging system, we focused on implementing functions, while ignoring the overall structure of the system. If we really use this method for software, after the system is delivered and used, O & M will become very difficult. When the software becomes a huge mud ball, we can only try to refactor and reinvent it.


How to properly use the design model?


Using patterns to improve existing design is better than using patterns in the early stages of design. It is designed through evolution rather than using large-scale pre-design, implementation through reconstruction, trend, and removal patterns, instead of using patterns in the early stages of design. The delay in the use of the model not only avoids the problem of over-design, but also considers the lack of design in the system.

 

By gradually improving the design of the code, we can gradually sniff out the bad taste of the code and find out where there is a problem, and most of the improvements are successful.





-- Refer to "big talk Design Pattern" and "Reconstruction and pattern" in the article


 

 







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.