Several empirical principles of Object-Oriented Design

Source: Internet
Author: User

During this time, Arthur J. riel's "object-oriented design heuristics" was read, so the following object-oriented design principles were summarized as a reference:

  1. All data should be hidden inside the class where it is located.
  2. The class user must be dependent on the public interface of the class, but the class cannot depend on its user.
  3. Minimize messages in the class protocol.
  4. Implements the most basic public interfaces that all classes understand, such as copy operations, equal judgment, and correct content input.
  5. Do not put implementation details in the public interface of the class.
  6. Do not disturb the public interface of the class with something that the user cannot use or is not interested in.
  7. There should be zero coupling between classes, or only export Coupling Relationships. That is to say, a class must be unrelated to the other class, or only operations in the public interface of the other class should be used.
  8. Class should only represent a key abstraction.
  9. Place relevant data and behaviors in a centralized manner.
  10. Put irrelevant information in another class.
  11. Make sure that the abstract concept you modeled for is a class, not the role played by the object.

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.