# Incremental Construction for Scalable Component-Based Systems
## 4 Incremental Construction in CBD
### Object-Based Component Models  
In this section, we go through the composition mechanisms for objects (from Figure 3) to explore the possibility of using them to increment the behavior of a system. In this section, we also analyze the possibility of incrementing a system by adding code. Objects/classes are composed by containment (class nesting, object composition and object aggregation), by extension (inheritance) and by connection (object delegation) mechanisms. For classes, containment and extension composition mechanisms construct a single class. In contrast, in OOD and CBD paradigms, a system is a composition of two or more objects connected by object delegation (message passing mechanism). The functionality of a single object (the _sys_ class) is the execution result of the object's _main_ method, as shown in Figure 6a. The system's behavior is to instantiate an object and to execute its _run_ method. For class nesting (from Figure 3), Java allows the code of inner classes (which are instantiated and used as normal objects) to be part of a class, as shown in Figure 6b. In order to achieve an increment in the system's functionality by the composed inner classes, code must be added to instantiate the objects of the inner classes as data members of _sys_ and then their methods must be called within the behavior of _sys_. Similarly, _sys_ can be incremented by multiple inheritance without overriding (Figure 7a) by the public members of the two parent classes C1 and C2. In invasive software composition [37],'single inheritance' is also a composition mechanism because this composes two independently developed fragment boxes (class boxes corresponding to classes in OOD), as shown in Figure 7b,c. The inherited class is a pair of inherited part and incremented part [38]. Composition in Figure 7b is incremental if _C1_ does not override any method of _sys_. As an alternate, composition in Figure 7c is incremental for not destroying (or overriding) the system's behavior. However, the system functionality is not incremented by class inheritance alone; the extended member methods must be called from inside the system's functionality. Object delegation is a composition mechanism which composes two objects by one calling a method of another object. In Figure 8, we increment the functionality of the system by adding a method call (shown in bold) to object C1 inside the functionality of the system. To increment a system's functionality, object delegation is an example of incremental construction if the method call is added in the behavior of the system. Figure 6: (a) Class nesting, object composition and object aggregation, (b) block diagram. Figure 7: (a) Multiple inheritance, (b) Single inheritance, and (c) Single inheritance. In aspects [26] (crosscutting concern), advices represent behavior that can be added at various join points. In Figure 9, we show how an aspect after weaving increments the behavior of _sys_. The aspect adds the effects of object delegations to object C1 in the method m1 of _sys_. To increment a system's functionality, aspect weaving is an example of incremental construction if an aspect is weaved in the behavior of the system. In mixin-class inheritance (from Figure 3) a mixin (an abstract subclass [27]) is composed with a class to increment the class. As with class inheritance, mixin-class inheritance without overriding adds functionality to the class but not to the system. Mixin-class inheritance with overriding overrides the functionality of the system; this mechanism is not behavior preserving and therefore not incremental. Trait is a unit of reuse [28] which provides a set of services (shown with lollipop symbol and undertakes some useful computation) and may also require a set of services (shown with arrow symbol). In Figure 10, we show a composition of a TDisplay trait with _sys_. Composing a system class with traits by trait-class composition does not increment the functionality of the system.