Avalon: Assembly Program Design (COP)

zhaozj2021-02-08  443

"Component-Oriented Programming, COP) has been taken for a long time, which makes it a bit like a buzzword. What is a COP? How to implement a COP system? Avalon is a nice reference.

What is copop?

Introduction

Component Oriented Programming, or COP for short, takes Object Oriented Programming one step further. Regular OOP organizes data objects into entities that take care of themselves. There are many advantages to this approach. I'll assume that you, being a Java programmer, Are Familiar with those.

It also has a big limitation:. That of object co-dependency To remove that limitation, a more rigid idea had to be formalized:. The component The key difference between a regular object and a component is that a component is completely replaceable.

COP is Not Just A Buzzword

There is a lot of buzz in the industry touting Component Based Design (CBD). You will find, that the definition of a component in Avalon is more formal than most companies' definition of a component. Any system developed with the principles of Avalon can claim CBD. In fact the Avalon Framework formalizes CBD more rigidly than the marketing definition. Do not be fooled though, CBD and COP are not necessarily the same thing. Component Based Design refers to how a system is designed and not how it is implemented ................................. ..

When implementing COP, an important design pattern is "Inversion of Control, IOC):" Hollywood Principles "for" Don't call US, We ', We', We ', We', We ', We', We ', We', "Hollywood Principles" enables each component to be independent. In addition, Avalon clarifies the principle of "Interface - Implementation Separation" with an extremely appropriate metaphor: Components are better than actors, and the interface is better than the script; the actor is always a lot, but it must be performed according to the drama; Framework is naturally the whole Director of the big play - the humanized description of the TMPLATE METHOD mode. Accurately, "script" is not only an interface (Interface), but also consracts. In the IOC system, Component cannot make any assumptions for other Components. During COP, Design by Contract is also useful.

COP in avalon

Components in avalon

At the core of the avalon framework is the component. We define it as "a Passive Entity That Performs a Specific Role". This is important to grasp Because IT Requires a specific Way of thinking.

A Passive API

A Passive Entity Must Employ A Passive API. A Passive API IS One That ITS ACTED UPON, VERSOS One That Acts Itself. See The Inversion of Control Pattern for an expection.

A Specific Role

The concept of roles comes from the theater. A play, musical, or movie will have a certain number of roles that actors play. Although there never seems to be a shortage of actors, there are a finite number of roles. I am not going To make reference to diffErth, but simply bring the concept to light. The function or action of a role is defined by ITS Script.

We are introducing this concept now because you need to have it in mind when you are designing your system architecture. Think of the different roles in your system, and you will have your "cast" of components so to speak.

For each role, you need to specify its script, or interface to the rest of the system. To be honest the interface is not enough. There are specific contracts that you must define and keep in mind when you specify your interfaces. In other words , what users of the component produted, and what the component produces .hen the interfaces and contracts area defined, you can works your importation.the component

John Donne wrote, "No man is an island." To communicate that we are all interdependent. The same is true for the component. That is why there are different concerns regarding the component. In the section on roles we specified one of the concerns : The role. The Concerns Directly Supported by The Avalon Framework Are: Configuration, External Component Use, Management, And Execution.

Note

WE Used to Have A Marker Interface Component. This Has Been Deprecated Because Requiring All Components Extend this Interface Makes Integrating Avalon with Other Component Systems Like

Corba Very Cumbersome.

As you might have guessed, each one of these concerns has a separate interface that describes that concern. We will delve deeper into the interfaces and the reasoning behind them in other sections. It is important to know the order of precedence for the concerns so that You know The Overall Contracts of How The isy is put together.

Configurable: marks an object that can be configured Serviceable:. Marks an object that uses components Initializable:. Marks an object that can be initialized Disposable:.. Marks an object that can be disposed Stoppable: marks an object that can be started and stopped .

The contract surrounding this order means that the methods defined by each of those interfaces are called in a specific order by the object created the component. Each interface represents a narrow view of the component or object being controlled.Note that

Notice That Each Interface Is Separate from Component, So You Can Use The The for Simple Objects.

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

New Post(0)