Architectural Design Principles-what are the appropriate classes?

Source: Internet
Author: User

As long as object-oriented programming is adopted, class layers are inevitable (including interfaces). Although there is a principle in object-oriented programming that multi-purpose interfaces use less inheritance, this does not mean that inheritance is not used, after all, inheritance can be implemented.CodeIt has its advantages. For your own class levels, of course, the less the better, but no matter how many is at least two layers, then 2-3 layers should be normal, 4-5 layers are a bit more, 6 layers and above, there will be more general application systems.

In my general application system, the class level is: the first layer, the top layer, which is generally non-fan type. It is used for the basic specifications and constraints of this class. The 2nd layer consists of two branches: Standard Functions and user-defined functions. The standard feature adopts the model.ProgramWhen the leaf class is used, the semantics is clearer without reverse conversion. The user-defined base class only provides the standard necessary constraints for users to handle non-standard situations. The third layer is the leaf type. The benefit of this hierarchy is that it can be inherited, and standard function classes can often use code generators to automatically generate code.

In general, the main focus is on solving 80% of the problems. The remaining 20% of the special problems can be solved by allowing users to define their own classes, in this way, the 80% part will not be too complicated due to some special problems of 20% or even less.

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.