Architect practice III - master design principles

Design principles for the software, there are many, to master the design principles, understanding, practice and sublimation is a very architect of the necessary practice. I remember reading "Agile Development" for the first time in 12 years ago, the five basic design principles have become deeply implanted in my mind has been affected so far, I have thus benefited. Of course, more than only five design principles, the most important object-oriented design principles have the following:
 
  • Single Responsibility Principle (SRP) - On a category, it should only be one causes of change
  • Opening - closing principle (the OCP) - software entities (classes, modules, functions, etc.) should be extended, but can not be modified
  • Alternatively Richter principle (LSP) - must be able to replace them subclasses base type
  • Dependency Inversion Principle (DIP) - abstract should not depend on the details. Details should depend on the abstract.
  • Interface Segregation Principle (ISP) - customers should not be forced to rely on the method of their unused. Interfaces belonging to the customer, it does not belong in the class hierarchy.
  • Reuse-order principle release, etc. (REP) - reuse granularity is released granularity.
  • Common Closure Principle (CCP) - All classes in a package of changes for the same type of property should be common closed. If a change is generated on the impact of a package, it will have an impact on all the classes in a package, but does not affect other packages.
  • Reuse common principles (CRP) - a package of all classes should be common reusable. If you reuse a class package, then it would reuse all classes in the package.
  • Acyclic Dependencies Principle (ADP) - present in the ring does not allow the package dependency graph.
  • Principle dependent stability (SDP) - toward a stable direction dependency.
  • Stable abstract principle (SAP) - level of abstraction and its package should be consistent with the degree of stability.
  • Synthetic / polymeric multiplexing principles (CARP) - To make full use of synthetic / polymeric, try not to use inheritance
  •  …..
 
Of course, the object-oriented design principles is much more than that, the design principle is accompanied by the accumulation of experience summed up the development of applications and software development experience in the development of language summary of the results, along with the evolution of language, progress will continue to develop methods and derivatives more evolved design principles. Application design principles can avoid many of the pitfalls and errors in design, but at the same time application design principles to keep in mind one thing: the box there is some experience on the design principles of nature, it is designed to guide cane rather than let them become bound design cage thought.
 
Each architect will gradually establish design principles of their own after experiencing long-term practice. Over the years I have summed up some of the design principles, these principles can be used in this design and the code above summarized as: "code design principle", the principle of consciousness and others used in the design process is called "consciousness - principles of conduct . " I am going to tell my experience are understanding and use of these design principles.
 

Awareness - principles of conduct

 
  Conscious decision to act, a lot of design mistakes is not simply derived from the lack of grasp of design principles, and more may result from errors in guiding architects of consciousness, so before you start the design should first establish the right ideas and consciousness guide. These less conscious - principles of conduct is I summed up in a fall from a lot of times some of the ideas, principles for the period as a time guidance he will not make mistakes in similar problems.

Adhere to the principle of innovation

  First talk about the design template, template I believe is a very good thing for every developer and designers, because it can be "quickly" build "mature" code, structure, or UI. "Ism" boom ever in the industry, in terms of a template for architects also have this effect, in the design process, we often encounter a lot must not important "tasteless" module, without which the system will become incomplete, and their presence does not add any "features" for the system, such as: user management, role management or system settings. Common practice is to direct the use of existing third-party modules or from other projects with similar multiplexing module, you are such a right? At least I always do this, because our projects are usually Chinese-style "acceptance driven" through acceptance, mature enough available. If the entire project is just a template of various types of modules, then the project did not really need an architect, because there is no design, all the work should be a "fusion" (Fusion). May be a lot of people would say Tucao say this is a "resource integration" capability, from a "rush project" point of view that no non-tasty, but said the technical content and design components of any nature does not exist, this type of assembly or "copy" of the project requires the project manager with only a few senior programmer will be able to complete.

I was in the " expression control thinking and methodology referred to" a paper methods of communication and marketing, among them a: "Name at least three of the characteristics of the system," This statement has implications for markets outside sales, in fact, is for architects play an important role also in establishing remind one design principles:

  Assembled architecture template design is inevitable, it is important to be added yours design features

It was hard to remember the entire software designer, and very easy to remember the great features of a particular designer. "Characteristics" is an important mark in the software architect left, also in where the team with the architect of significance. Design a fully templated reuse design is a skill, and date of this design is the emergence of an enterprise when architects leave within small and medium enterprises, and perhaps this is the moment of the Chinese architect War. Maintain the characteristics to keep their jobs, you know.

 

Stick to the principle of nature 

  The only constant is change itself  - Jerry Marktos "Mythical Man-Month"
  Just the same desire to change is eternal  - Swift
 
This is not to see two classic guess I would like to "change" word come once commonplace? In actual fact, the word also discussed the estimated 20 years in the industry, also said rotten. The reason I quote these two masters of saying just wanted to remind myself all the time to understand every change around, interested in their source, giving you insight. There will be no reason to love the world, there is no reason to hate all things are the root cause, it is the "essence." Let the "essence" and "change" These two philosophical issues into the iterative software development point of view within the context of a software product:
  • The user needs to change - they need to add more features, more demanding quality user experience.
  • Code changing - constantly refactoring, testing, continuous integration, so that the code reads the contents become stable.
  • The boss's idea to change - because the market demand is changing, the need to add more features to the software to meet the market.
  • Architecture is changing - the use of newer technology system, to obtain more efficient productivity, more stable, secure operating environment.
 
The only constant is: core software. As: Windows version last changed N or operating platform, Office derived from the processing documents in the file if so many generations.
 
  Change is like a table, unstable and customizable; nature is a core, must be stable, scalable, and can not be modified; changes can be fixed into the core.
 
  Architecture should start with nature, all complicated things should be broken down into a simple principle and structure, something other than nature Jieke change. Let's illustrate, an e-commerce website design, the core can be broken down into "shopping cart" and "Order Status Tracking" Unless the public's overall shopping behavior has changed in nature, in order to increase the user experience which is immutable we use beautiful and comfortable interface kit as BootStrap, if further enhance the user experience you can use the SPA architecture allows customers to get Native-like experience on the Web; to allow users to use a different payment method, we need to define the payment gateway interface ( introducing change) support existing payment platform, also left for future expansion of payment platform "might" occur. In order to enhance site stickiness to the user, we need to increase community module, and use cloud storage or other BigData technology to support the large amount of data operation; .... Finally, the essence of everything remains the same, the electricity supplier website, change is the scalability, ease of use, flexibility and so on. Architects can add functionality to which too much, but you must stick to the essence in order to make the product does not become a monster to build out a high-tech, refer to "Merchant Code" principle when adding new features guidelines.
 

"Merchant Code" principle

Never invest in the future, not the design function does not return

I do not know whether you have a similar experience:

  • Communication with clients, your boss and managers are constantly depicted the "future" picture of customers, but in a lot of features which contains almost no customers need?
  • When you design the overall architecture, there is an impulse to make you want to be an inspiration triggered by the function or module for the "future" of the need to expand the system useful to join it?
  • In your code there are a number of methods or classes can be deleted, but you think they can be used for "future" expansion and "men leave code" of it?
  • Do you have a manager or a project leader for whether the increase is likely to be featured and debated it you realize it is a function?

  Measure ruler in the hands of architects, if there are numerous of these "future functionality" appears in the design, how would you treat it? Is a direct cut or wrapped as "features" mean? At this time, the architect not only require a technician's point of view as to consider this feature is available in the future, but more of a need to consider the "cost." Each function or even every line of code is required to pay the "man - months' costs, once the costs out of control, the software will be the embodiment of" crying wolf "swallow your project, and finally can only regret not having found a" silver bullet. " Each "future" how to function not bring immediate returns of the existing project, you must cut off! Even if this function how wonderful, profound or extraordinary significance in the future, or put it in "laboratory" has become the technical reserves other projects now. Businessman standing position: every penny of the cost of inputs, we need to have enough interest returns .

  The future is always good, but also full of clouds, but the reality is often full of skinny. Overdraft in the architecture or code in a handful of future returns available, because these "investments" are just some of the unpredictability of attempts, in addition to the product "marketing strategy" requires too much out of this type of investment you have to have caught "Maintenance future" psychological consciousness. New features, future characteristics should be collected, as it releases an option, through detailed market research to reconsider added to the product. Of course, for the principle of large software companies are basically superfluous, because many mature software companies control the demand and extremely strict specifications. But if your business where there are no such management awareness, or an aloofness of design freedom, then this principle is very important, we are people who use the code to change money, less code to change more money is our the most basic survival needs.

 

Reconstruction of the principle of priority

In the absence of the code should be reconstruction, reconstruction method is to write elegant code rather than simply modify the code theory.

Camels and tents story

  Filled with sand in the desert, camels in looking for a warm home. Later it finally found a tent, but the tent is someone else (maybe your situation is saying the same)! 

  Initially, camel begging that the owner, I feel dead, let me put your head to ease warm it! Poor master it, agreed. After a while, the camel said, the owner, my shoulder froze numb, let me come a little bit! Poor master it, he agreed. Then, camel constantly requested, trying to put the whole body. 

  Owner of a little hesitation, on the one hand, he was afraid of coarse camel's nostrils; on the other hand, outside of the sand so much, he seems to need such a partner, and he co-resist cold and dangerous. So he turned to go back somewhat reluctantly, to camel free up more seats. Camels and wait until the full spirit can take control of the tent when it is said impatiently, the owner, the tent is so small that even I turned very difficult, you gave me out of here

  This is a very moral of the story, if it is a metaphor for the development process is also very interesting. For the "smelly" or even "rotten" the code we will immediately say, "reconstruction", but if you can reconstruct solve all the problems? Have you tried to reconstruct failure? Reconstruction under what circumstances it is not available? If these problems in your heart there is no accurate answer, I suggest once again to read "Refactoring" book. I believe that the reconstruction is not simply a method of development and review of the code used, but an ideological guide the design and coding! In the design phase should apply the principles of reconstruction, whether it can "preservative" mean? The answer is clearly determined. Reconstruction is often not simply the code, but the idea of ​​developers, designers, non-execution or no code specifications, any name, free copy / paste, free call these must be eliminated. I do not mean in the design of the reconstruction does not need reconstruction, but the significance of doing so can significantly reduce the cost of the discovery of "stinking" Reconstruction of code away.

  This can also be said that the principle of the development of a team, at the beginning of the project have to have a unified coding standard (direct use of official specifications), the base code reconstruction method and remodeling also included in the specification, in the development process enforce norms, codes for any possible "corrupt" absolute "zero" tolerance, the pain is only temporary, but the benefit is long-term.

 

Code design principles

 

Open - Closed Principle 

Open Closed Principle, also known as open - closed principle Open-Closed Principle (OCP) 

Software entities (such as classes, modules, functions, etc.) should be extended, but it can not be modified.

  OCP is a very well-known design principles of a simple sentence can be summed up when the "open" to when the "closed." This sentence seems very simple, a look will feel that they seem to comprehend what chew felt within the meaning unlimited, how in the end it should be understood these words and apply it to design it? I refer to a lot of domestic data summarized this principle, the feeling is smoke and mirrors, no way to find the most appropriate explanation.

I would like to explain several aspects of this principle:

From the perspective of design class

  Open Application class designed - closing principle is a principle of control of the class "polymorphism." Opening and closing the principles in the design of the base class or superclass by important, it can simply geography for the  members of the object's scope  and  members can "reload"  Control Guidelines principles. Press "Richter replace the principle of" base class members are usually for subclass should be seen, that is the smallest scope scope base class members should protect, if the emergence of a large number of private members should consider private members separated into other categories, these members do not apply because its progeny violated "substitution principle", and more suitable "principles synthetic / polymeric."

  When using the virtual keyword to be very heavy consideration, except for some special design patterns such as "decorative" virtual mode requires a lot of outside support, in the absence of the necessary circumstances to avoid. Rewritable defined subclass members reserved the room "behavioral change", but also as a subclass of violation "substitution principle" laid mines. When a large number of subclasses override member appears in the time you have to consider whether the sub-class also should inherit to such family, because a large number of subclasses in violation of "substitution principle" means that it meets the separated family class condition. Similarly, in C #, but need to achieve a base class inside a subclass needs to taken into account when the same interface.

 

 Note: Substitution Principle Leeb is open - an important complement Closed Principle, usually use in class design.

 

From the perspective of a modular design

  Module Design "opening - closing principle" is focused on the control of the interface. And this is particularly important in the overall architecture, as between modules "open - closed" is a direct impact on the system level coupling. Opening and closing need to "weigh the cost" between modules, not all the details are open to using modules is highly scalable will have a high degree of reuse. First look at to understand that:

Openness and maintenance costs proportional

  Open interfaces must with instructions for use, this will increase the cost of a team of communication open while a change in the interface but will likely bring additional "descriptive reconstruction" cost. In some cases it is easy to be "highly scalable" the lure will expose a lot of "likely" to be multiplexed by extending the interface. When the temptation of this highly scalable leading designer of thinking, along with an increase in the module becomes large projects, will enter slowly designer created his own "Notes nightmare" in.

 

Openness and proportional to the degree of coupling

  Interface modules having open conductive coupling effect, the coupling between the control modules can be controlled to a large extent the coupling degree. Dependencies among the modules, the lower the degree of coupling is more easily possible to change the degree of coupling concentrated in one of the two modules (eg: Facade mode), rather than scattered among modules. High coupling module has naturally become the "core" modules, but in fact the "external" modules will need to maintain their closure, this design is easily adapted to many changes in the unknown.

 

This positive relationship between the two combine to achieve cost control on us to make two of the most simple and practical reasoning:

Corollary 1: "Please remain closed under normal circumstances, the absence of necessary not open."

Corollary 2: "focus on openness, so keep the strange inter-module"

 

Open - Closed Principle talk there will be a lot of content in theory, but the implementation is very simple, it focuses on C # The easiest way to control the control module is an open scope: internal, public.

 

3. Design from the function / method angle

I used to think OCP extreme case is applied to the method level, is well known: the fewer the better use of parametric methods. Opening - closing principle can be simply understood as a control parameter value will return to the amount of

 

Here I want to talk about - "Opening the Closed Principle" in C # is. First methodological design, C # gives designers and developers a great deal of space to the 4.5 method parameters we can even use async methods to control simple asynchronous method, then the first to sum up the kind of C #.

  • Fixed parameters: public void methodName (string a, out b, ref c);
  • Dynamic parameters: public void methodName (string a, string b = "defautlString") 
  • Variable parameters: public void methodName (params string [] a);
  • Expression (injection method): public void methodName (Func <string> func, Action act);
  • Generic parameters: public void methodName <T> (T a) where a: class;

In C # we need from you to think and give full play to the characteristics of the language itself, to simplify the code to enhance readability effect "injected" in this regard. Here to talk about "injected" mainly refers to two aspects, one is the "code injection", the second is "the type of injection."

 

"Code injection" method is to pass a "proxy" class inside the method is to open up a "scalable" to perform part of the unknown, variable functions, then we can enhance its relatively "closed" approach " open "nature.

By using the generic method, we can relatively common operation type "closed" in the case of type "open" up, so that the composite can be used largely replaced generic class inheritance, polymorphism reduced class Coupling.

 

Richter Substitution Principle (LSP) 

  Where applicable local base class, subclass necessarily apply
 
One of the basic principles of Richter substitution principle (Liskov Substitution Principle LSP) object-oriented design. Richter substitution principle in that place any base class can appear, sub-class will be able to appear. LSP is inherited cornerstone multiplexed only when the derived class can replace the base class, the software unit of functionality is not affected, the base class can really be reused, derived class can add new behavior on the basis of the base class on . Richter substitution principle is - to add "on-off" principle. To achieve "open - closed" principle is a key step in abstraction. The inheritance relationship with a base class is a subclass of the abstract concrete realization, so Richter substitution principle is the specification for concrete steps to achieve the abstract.
 
Foregoing "opening - closing Principles" based on the design described in the application part has substantially the "substitution principle" usage. This principle, I have been reversed to understand, so it is very easy to use, so I use:
  • A large number of members who appear subclass does not apply, it should be from a subclass inheritance
  • Where a large number of base class virtual member, the class lost condition becomes the base class
 
 
 

Dependency Inversion principle (DIP) 

   To rely on the abstract, do not rely on concrete.
 
  DIP as LSP as original and the translation is actually very pit father, I will not be introduced directly into the original, because I hope that everyone reading this article friends can understand and apply these principles rather than playing with words. DIP with the most simple expression is: "programming to an interface." Subclass can refer to a parent class methods or member, while the parent is absolutely not call any method or subclass members. However, a method of adjusting the upper class is called a subclass of method will depend form a ring, the general compiler "miss" that this is not a dependency loop logic errors, but the class structure having ring is not dependent of the sequence ( in C # directly thrown cyclic references).
 
Popular point: " the rules are given ancestors, descendants and improvement can only be performed " with the mouth can never fully grasp this principle.
In the past (10 years ago) is still relatively backward development tools, this is a very important principle, and now can use to find out VS.net this design error, you can directly use IoC and DI will naturally and fully honored this in principle.
  

Interface Segregation Principle (ISP)  

  Using multiple specialized interface is better than the applicable single interface
 
  Architect in the world is the logical process of God, it is to create a logical design of the software world, each of the interfaces is a kind of rule the world, is the realization of class rule practice example is the implementation of the rules of the people. In the implementation work, we often encounter this phenomenon: a PM may follow several projects at the same time, or a PM to simultaneously act as architect, PM, programmers and even pre-sales roles, who are these bitter B the most tired of people within the company, but also the group with the highest failure rate, why? The answer is obvious: a person's energy is limited, concentrate on a certain thing can really bear fruit. Similarly, in the logic of the world is the same, when the class interface to host a variety of tasks, there will be "Interface overloaded" or "Interface pollution" is called by many different classes that implement these interfaces will produce high the degree of coupling, so that the code will be difficult to read, difficult to understand, difficult to change. Separating the interface is to isolate the client (user interface), the client isolated naturally reduce the coupling.
 
  A perfect world it should be someone special, so that people are good at doing its good things, but in reality impossible logic of the world can. So how in the design of such principles to grasp it? Very simple, when the method on the interface is more like a call will alert, if no dependencies between these methods, even a method different categories (doing different things) so you have to consider the principle of ISP interface separated into two separate interfaces, interfaces that the degree of coupling is reduced from 1..1 to 1..n. 
 
 

Synthetic / polymeric multiplexing principles (the CARP)

  To make full use of synthesis / polymerization, try not to use inheritance
 
  Multiplex principle is an easily overlooked but extremely important principle, which has far-reaching significance of architecture. For small projects (small library) even in violation of this principle will not bring any harm, but to build a large-scale library (hundreds or even thousands of classes), the principle can prevent the emergence of "Inherit out of control" , excessive expansion, the risk can not be reconstructed, etc., but also determines the reusability and maintainability of the whole structure. It is just a simple thing, but the "inheritance" in the definition, "synthetic" and "polymerization" leads to a series of contents, covers a variety of design patterns provided with the application and principles of the plurality of smaller levels.
 
(Note: the benefits of synthetic / polymeric, please go to Baidu it, on the "white box multiplexing" and "black box reuse" are transferred rotten)
 
  We must first correct choice synthesis / re-use and inheritance, we must thoroughly understand the Richter substitution principle and Coad law . Coad law proposed by Peter Coad, summarizes some of the inherited condition as when to use reuse tools. 
 
Coad rule:

Coad only when the following conditions are met, you should use inheritance:

  1. Subclass is a special kind of super-class, rather than the role of a super class. Distinguish "Has-A" and "Is-A". Only "Is-A" relationship is consistent with inheritance, "Has-A" relationship should be used to describe the polymerization. 
    • "Is-A" is representative of a class of another class;
    • "Has-A" on behalf of a class is another role of a class, not the other kind of a special class. 
  2. Never appear necessary to subclass into another case of a subclass of class. If you are not sure whether the future will become another subclass then, do not use inheritance. 
  3. Subclass superclass with extended responsibilities, instead of having a replacement out (override) or written off (Nullify) responsibility superclass. If a child requires a lot of class displaces the superclass behavior, then this class should not be a subclass of the superclass. (Note: The method comprises the new C #, attributes and internal implementation is equivalent to a single base class interface nullify)
  4. Only meaningful taxonomic point of view, you can use inheritance. Do not inherited from the tools. 
 
For a veteran Coad law is only a summary, it is easy to understand and use, but if you are a novice Coad framework law is very pit father (my understanding is very low, then I was the pit for a long time)! So I want to open a new path from another point of view to try to explain this principle.
 
Inherit control
Inheritance is an important object-oriented configuration, multiplexing principle, only tells us that "as far as possible not to use inheritance" instead of inheriting the devil, in many scenarios, small inheritance structure is very common and easy to read. But, we need to understand the increase of offspring to inherit the entire class based on the complexity of the structure of the n-th power increases in increments, with the increase of Change "class family" structure offspring hierarchy to become increasingly difficult. In fact, we can find some examples of their own hands to see if there are more than three generations of inheritance class, to see whether a little "beyond recognition" among the smallest descendant class base class? This is with human reproduction and inheritance is very similar. And then "substitution principle" is a little deeper if extended to the topmost base class, it can be fully applicable to it? Is there a "sword waving" like heaviness when you change the high level structure? To have the courage to stability ancestor class remodeling?
 
Corollary: "as far as possible to avoid inheritance than three generations occur, or should be considered synthesis / polymerization"
 
 
"Synthetic" and "aggregate" from the literal sense and that is what I have been unable to understand properly. I may be the language level is too low because of it, and Aggregation for Composite two words I would be able to find the exact definition on Wikipedia.
 

Synthesis of (Composite) - the value of polymerization (Aggregation by value)

I popular definition: synthetic process configuration process class (constructor constructor or external) or other value assembled into a class instance at runtime synthetic (or attributes by variable Hold live)
 
Such as:
public class Keyboard{}
public class Mouse{}
public class Monitor{}
 
public class Computer
{
    private Keyboard keyboard;
    private Mouse mouse;
    private Monitor monitor;
 
    public Computer() 
    {
         this.keyboard=new Keyboard();
         this.mouse=new Mouse();
         this.monitor=new Monitor();
    }
}

It is seen from this example, so-called "value (the Value)" Synthesis internal member "Computer" in the constructor, like the individual functional components assemble into a single powerful product. All dependencies are "off" within the constructor, if the use of the plant can be dependent on external (Factory Pattern) and a combination mode (Composite Pattern) evolve.

public class Item{};
 
public class Keyboard:Item{}
public class Mouse:Item {}
public class Monitor:Item{}
public ComputerFactory 
{
   public Item Keyboard() { return new Keyboard(); }
   public Item Monitor() { return new Monitor(); }
   public Item Mouse() { return new Mouse(); }
}
 
public class Computer
{
    public List<Item> Items{get;set;}
    
    public Computer(ComputerFactory factory) 
    {
        this.Items.Add(factory.Keyboard());
        this.Items.Add(factory.Mouse());
        this.Items.Add(factory.Monitor()); 
    }
} 
A simple evolution, can be coupled into the coupling Computer 1-3 1-1, and all the dependencies are concentrated on ComputerFactory, only need to inherit ComputerFactory create more factories incoming Computer class can produce a variety of Computer variety of instances, without having to change any code Computer, this is the so-called "black box reuse."
 
Thoughts: Try to rewrite the above example with the Builder mode, there will be different results.
 
Here there are only three members, but if 30 or more member becomes just "synthetic constructors" is changed to deal with more complex scenarios: Synthesis tree structure is configured only by the evolution of a recursive structure . This shows the power of the principles of operation of "synthesis" of the large number of classes combined.
 
 

Polymerization (Aggregation) - references polymerization (Aggregation by reference)

 
Polymerization on an object-oriented implementation is a very simple code, it means: object properties. In the above described first example (not inherited class Item yl)
 
public class Computer
{
   public Mouse Mouse{ get;set; }
   public Monitor Monitor{ get; set; }
   public Keyboard Keyboard {get;set;}
}
 
public class Host
{
    public static void Main()
    {
         var computer=new Computer()
         {
              Mouse=new Mouse(),
              Monitor=new Monitor(),
              KeyBoard=new KeyBoard()
         };
    }
}

  Hold live polymerization class is a reference to the instance of the class, not only is the value. Polymer of class that references a concentration-dependent, is also said that this class Computer Facade pattern from a certain sense. In this way the entrance is common in large-scale class object model, such as the Office of the Application object, such a design can be for developers to "find" a reference to the class. While the design can also be used as context: .net in System.Web.HttpContext. It is noted that: the aggregate class with caution is needed for convergence of the class itself is coupled referenced class, while also having a characteristic coupling polymerization type conduction, by the constructor. Take EF say do it, we all need to access the database with EF code like this:

public void OrderManager
{
    public List<Order> GetOrder()
    {
        using (var ctx=new DbContext( )
        {
            //
        }
    }
}

When this new code will appear in the entire bad dishes! The coupling structure referenced once every call to increase one point, when even layer over the entire access system DBContext is a super-giant coupling unalterable tumor! To resolve this problem in one piece or mode may be configured with self IoC, DI is configured to move to a central place, to prevent the spread of the coupling structure. 

summary

  If you are a .net developer systems, as long as you open the code checking rules vs.net you will find a new world, a principle / norm-based world, if your code can be by 80% vs. net the highest level of code review guidelines, then the fact that your code is already very high. Each code checks within the guidelines are worthy of our careful to taste and learn.

Reproduced in: https: //www.cnblogs.com/Ray-liang/p/3859024.html

Guess you like

Origin blog.csdn.net/weixin_34007879/article/details/94195944