Avalon Basic Concept (1) - Component Programming (COP)

zhaozj2021-02-16  78

Component programming (COP)

COP is further more than OOP. Usually OOP tissues data objects into entities. This approach has many advantages. However, OOP has a large limit: the interdependence between the objects. A good idea to remove this limit is the component. The key difference between components and general objects is that components can be replaced.

Any system developed using Avalon can be referred to as component design (CBD). COP and CBD are not the same concept. CBD refers to how a system is designed, and COP refers to how a system is implemented.

Design component

The first step to write a component is to determine how to use it. If you have a powerful component that can be used in many different context environments, you can be reused. These context environments include one part of the subsystem as a part of the subsystem, or as a full portion of Avalon.

Since all components are part of Avalon, then what to do is to define their interfaces (Role). It is important to identify and documentation contract for other parts of the system. The contract I have referred to is the order of dependencies, what is it required at runtime, what is it to provide other parts of the system.

It is important to have a careful plan during the beginning. Because you need to be used universally and accurately indicate its role interface.

Because the context environment may be part of Avalon, you must pay attention to the use of these components in the Avalon. This means that when you define a relationship, you should follow the relationship order of Avalon.

When designing a component that can run in the command line, try to separate the main () function from the component. This is to maintain the mandatory of Avalon's PASSIVE API. Design components in the previous way, you will minimize the main () function.

Follow the habits below: Have an object that deals the main () function, including parsing command line parameters and initialization components. Using this method In each context environment, you can minimize the location where you need to find it when you debug.

转载请注明原文地址:https://www.9cbs.com/read-16836.html

New Post(0)