Six basic principles for Object-Oriented Design

Source: Internet
Author: User

I believe that programmers who have been doing software development for a few years will have such a sigh: "the coupling of this program is too high and cannot be modified. If you really want to extend the function, you can only write it again! ", "This piece of code is too messy. I haven't understood it for a few days !", "The newly added function is useless to the original code !"......

I have heard a lot of such sighs, especially when performing maintenance or version upgrades. The root cause of these problems is that the scalability and reusability of those systems are too low or even not.

So how can we make the system reusable and scalable?

I think there are several processes and steps to achieve this goal: 1) There is a pain point, and the deeper the experience, the better. 2) there is a desire for knowledge and willingness to explore unknown things. 3) with a deep foundation for programming, you must thoroughly understand what interfaces are and what abstract classes are. 4) You must thoroughly understand the basic principles of OO design. 5) You must thoroughly understand and understand the design model, in particular, 23 GOF Models

The following is my learning experience and experience on what interfaces are, what are abstract classes, and the basic principles of OO design.

What is an interface?

......

What is an abstract class?

......

What are the OO design principles?

"Open-Closed Principle or OCP" Principle)

Liskey replacement Principle (Liskov Substitution Principle or LSP)

Dependency Inversion Principle or DIP)

Interface Segregation Principle or ISP)

Combination/clustering Principle (Composition/Aggregation Principle or CARP)

Lawof Demeter or dump)

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.