Design patterns learning - leader

We need to have knowledge of seven points

  1. Object-oriented four properties: encapsulation, abstraction, inheritance, polymorphism,
  2. Object-oriented programming and the difference between process-oriented programming and links
  3. Object-oriented analysis, object-oriented design, object-oriented programming
  4. The difference between abstract classes and interfaces and their respective application scenario
  5. Rather than implement programming interface-based design ideas
  6. Multi-purpose combination of design thinking less inheritance
  7. Anemia Model process-oriented and object-oriented model of congestive

Design Principles

Design principles guide our code design some of the lessons learned. For each design principles, we need to know that it is designed, which can solve programming problems, what scenarios. Only in this way can we in the project flexibly proper application of these principles.
Common design principles:

  • SOLID principles -SRP Single Responsibility Principle
  • SOLID principles -OCP principle of opening and closing
  • -LSP SOLID principles in the replacement principle
  • SOLID principles -ISP Interface Segregation Principle
  • SOLID principles -DIP Dependency Inversion Principle
  • DRY principle, KISS principle, YAGNI principle, LOD law

Design Patterns

Design patterns are for some design problems in software development often encountered, summed up a set of solutions or design ideas. Most design patterns to solve the codes are scalability issues.
Classic design mode 23 species. They can be divided into three categories: creational, structural, behavioral type.

1. Create a type
commonly used are: single-mode embodiment, the factory mode (factory method and abstract factory), the builder pattern.

Not commonly used are: prototype model.
2. Structural
commonly used are: proxy mode, bridge mode, decorator mode, the adapter mode.
Are not commonly used: Facade mode, combination mode, Flyweight.

3. Behavioral
commonly used are: the observer pattern, template mode, strategy pattern, chain of responsibility pattern, the iterator pattern, state pattern.
Not commonly used are: a visitor mode, the memo mode, command mode, the interpreter mode, the intermediary model.

Programming Specification

Programming specifications mainly to solve the problem is the readability of the code. Coding standard with respect to the design principles, design patterns, more specifically, more emphasis on the details of the code.

Even if you might not be familiar with the design principles of design patterns do not know, but you should at least master the basic coding standards, such as how to variables, classes, function names, how to write code comments, function not too long, not too parameters and more and more.

For coding standards, considering that many books have been put very good (such as "reconstruction" "Code Complete" "Code tidy way", etc.).

Refactoring

In software development, as long as the software is constantly iteration, there is no design once and for all. As needs change, the code kept piling up, the original design will certainly exist such kind of problems. To solve these problems, we need to code refactoring. Reconstruction is a very important aspect of software development.

Continued reconstruction is an effective means of maintaining code quality does not decline, can effectively prevent the code from the hopelessly corrupt. The reconstruction tool is listed in front of us who object-oriented design, design principles, design patterns, coding standards. In fact, the design ideas, design principles, a design pattern is the most important application scenarios in the reconstruction of the time.

Although the use of design patterns can improve the scalability of the code, but improper use of excessive, will increase the complexity of the code, it affects the readability of the code. In the early stages of development, unless you must, be sure not to over-design, application design complex patterns. But when there is a problem in the code, we then reconstructed for the problem, apply the principles and patterns. This can effectively avoid over-designed early.

For the reconstruction of this part, you need to have knowledge of the following points:

  • Objective (why) reconstructed object (What), timing (When), method (How);
  • Reconstruction techniques do not guarantee error: unit testing and testability of the code;
  • Two different sizes reconstruction: reconstruction of large (large-scale high-level) and small reconstruction (small-scale low-level).

Guess you like

Origin www.cnblogs.com/Utah-Lee/p/12390551.html