Communication entityentity

Entity classes represent concepts from the problem domain. They interact with each other to provide the required functionality. Often, objects created from entity classes reside in the same memory space or machine. Therefore, the associations representing the collaborations between concepts are from one entity class directly to another. In this architecture, entity classes are closely coupled to each other. This solution works well in cases that monolithic systems need to be developed; all objects will reside in the same area space and there is no need to substitute the behavior of an object with some other one. Changes to the system can be done only by developers that are familiar with system's architecture. Therefore, these systems are usually not flexible and provide little reuse of functionalities incorporated in the system. There are cases where this architecture is acceptable and provides good results.

There are other cases that although entity objects belong to the same domain, linking them directly to each other may create problems related to the reuse and extendibility of the future system. It would be desirable to have flexible systems that allow for replacing one class or component with some other ones that provide similar functionalities. As an example, some other institutions or individuals may have developed a soil or a plant class/component that we would like to use in our system. In this way knowledge can be transferred easier, collaboration among scientific institutions and/or individuals will be better, and the time for developing a new system will be shorter.

In the case of the Kraalingen approach, the conceptual model shows that entity classes are in association with each other. The collaboration between classes in the conceptual model reflects the fact that plant grows in soil and processes occurring in plant and soil are impacted by the weather conditions. Class Plant has an association with class Soil; both classes are tightly coupled to each other. The Plant class définition has an attribute of type Soil that is a reference to an object created from class Soil. The situation is similar in the Soil class definition; an attribute of type Plant, defined in class Soil, is a reference to an object of type Plant. Objects Plant and Soil are tightly linked together; none of the objects can be reused separately. The same can be said for the case of each of Plant or Soil classes in relation with class Weather. Objects created from classes Plant, Soil, and Weather form a monolithic system, none of its composing objects can be used separately. Figure 8-25 shows the direct links between the above mentioned classes.

In order to make the system flexible and extendable, hardwired associations between classes should be avoided and interfaces be used instead. As we have previously mentioned, the use of an interface is similar to providing a plug that can be used by any class that implements the same interface. The modified class diagram for the Kraalingen approach is shown in Figure 8-26.

As shown in Figure 8-26, the hardwired associations among classes have been replaced with associations between a class and an interface. Therefore, the attribute soil in the Plant class definition is of type ISoil, which is the type of the interface that defines the behavior needed from class Soil. Therefore, any class that provides similar behavior to class Soil can be used in the system, provided that it implements the interface ISoil. Classes implementing the same interface can be used as a substitute to each other. By replacing the association Plant-Soil with the association Plant-ISoil, we have created the possibility to use any other Soil class that may have a different implementation of the required behavior but it can be used in the system because it implements the interface ISoil. The same reasoning could be applied to the associations Soil-Plant, Plant-Weather, and Soil-Weather.

mePfmiùaia mePfmiùaia

ISoil

Figure 8-26. Classes have associations with an interface.

ISoil

Figure 8-26. Classes have associations with an interface.

Was this article helpful?

0 0

Post a comment