Components are software building blocks that allow us to assemble a system in such a way that any of these parts can be changed and rebuilt
without requiring the entire system to be rebuilt.
System factored into policy, implementation,
and utility components
and utility components
Example Component Structure
- Components are packages that export only two things: 1) an interface, and 2) an object factory. Clients can create instances of all the objects the package needs to implement its services using the object factory. The factory returns a package interface pointer, bound to its internal implementation. The client uses the interface to access package services.
- The interface allows clients to bind to a service abstraction without binding to any implementation detail. The factory supports initialization of the service without binding its clients to that startup process. Hence, clients are completely isolated from the component implementation.
- The first diagram shows a sensible decomposition of a system into a policy part responsible for meeting application requirements, an implementation component that implements the policy using a utility component for low-level operations. In a real system, each of these would probably be implemented with more than one component.
- If this decomposition was implemented with ordinary classes, the result would be concrete bindings that linked all levels of the system. Changes to a low-level utility part could cause breakage all the way to the top policy parts.
- Using the component structure, e.g., exposing only interfaces and object factories, a component at any level can be modified and rebuilt without causing any design or compilation breakage. We simply need to relink the component into the system. If we build each of the components as dynamic link libraries (DLLs) loaded by an executive, then we don't even need the link phase. We simply modify and rebuild the component and copy its new DLL into the directory where the executive looks for libraries to load. That replaces the old component with the new one. Since libraries are loaded when the executive starts, the new part begins its service.
Conclusions:
Using components to configure our systems makes developing and maintaining large systems much easier than it would otherwise be. Software
like the Windows operating system could not be effectively constructed without using a componentized structure.
- All components export only interfaces and object factories, and are packaged as DLLs.
- The componentized system structure consists of an Executive package using the services of components to implement most or all its functionality.
- To change a component, perhaps to fix a latent error or performance problems, simply modify the text of the component, rebuild its DLL, and copy into the directory from which the application loads its DLLs. There is no need to rebuild any other part of the system. That is critically important for large applications.
- This has the added advantage that all the component parts of the system can be tested with an automated "Test Harness".
- Continuous testing and integration is a part of many modern software contruction processes. The componentized structure is an essential part of that.