Application of the open/closed principle in the SCA Architecture

Source: Internet
Author: User
Tags sca

The open-closed principle (open-closed principle) is the cornerstone of object-oriented reusable design (Object Oriented Design or OOD. Other design principles (the Lee principle of substitution, the principle of dependency inversion, the principle of synthesis/aggregation reuse, the principle of Demeter, and the principle of interface isolation) are the means and tools for implementing the "open-closed" principle.

Definition of the "Open-Close" Principle

Definition: A software entity should be open to extensions and closed to modifications.
(Software entities shocould be open for extension, but closed for modification ).

When designing a software system module, the module should be extended without being modified, or, you can change the behavior of this module without having to modify the original code.

Advantages of a system that meets the "On-Off" Principle

1) by extending existing software systems, new behaviors can be provided to meet new demands for software and make the software systems in change adaptive and flexible.
2) the existing software modules, especially the most important abstract layer modules, cannot be modified any more, which makes the software system in change stable and continuous.
A system with two advantages is a system that achieves reuse at a high level and is easy to maintain.

Implementation of the "Open-Close" principle -- Abstraction

Object-Oriented programming languages can use abstract methods to define an abstract design that will not be changed for the system as the abstraction layer of the system. This abstraction layer covers all future extensions, so it will not change in any situation. In this way, the abstraction layer of the system remains unchanged, so that the second point of the open and closed principle is met: Disable the modification.

One or more classes exported from the abstraction layer can change the system's behavior, because the system design is open to expansion and thus satisfies the first point of the open and closed principle: open to expansion.

In the SCA framework, the application of the open/closed principle can be seen in both commonj and SPI; composite and component.

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.