[ACCEPTED]-Terminology: What's the difference between a class and a component?-terminology
what about using the project phase or role 9 to differentiate them?
For example a component is a design-time unit (system 8 architects, designers) whereas a class is an implementation-time unit (programmers). So 7 designers speak about components (or subsystems 6 or modules, the hight-level boxes in your 5 architecture drawing) whereas programmer 4 speak about components and classes (that 3 implements components).
Under this view 2 a component is implemented by one or more 1 classes.
I often think of Component in the UML sense 7 (see Wikipedia description), whereby it represents 6 a "modular part of a system". In 5 this sense it tends to represent a larger 4 piece of functionality than a class and 3 could in fact be composed from multiple 2 classes.
Considerations I would give to designing 1 components are:
- How it could be re-used. In particular what are the use cases that warrant implementing something as a component rather than bespoke code (As a grad I used to make everything re-useable!)
- Providing sensible interface(s), and in some cases additional simplified interfaces, perhaps using the Facade pattern.
Hope that helps.
In this (hypothethical) context a component 7 can be thought of as a series of classes.
However 6 depending on the technology you use, components 5 can be more then a set of classes. i.e. They 4 may have additional properties and functionality 3 which is not part of the classes which form 2 them. e.g. a COM+ component.
So it depends 1 on a specific situation really.
According the UML v2 specification:
8.3.1 Component (from BasicComponents, PackagingComponents)
A 21 component represents a modular part of a 20 system that encapsulates its contents and whose 19 manifestation is replaceable within its 18 environment.
A component defines its behavior 17 in terms of provided and required interfaces. As such, a 16 component serves as a type whose conformance 15 is defined by these provided and required 14 interfaces (encompassing both their static 13 as well as dynamic semantics). One component 12 may therefore be substituted by another 11 only if the two are type conformant. Larger 10 pieces of a system’s functionality may be assembled 9 by reusing components as parts in an encompassing 8 component or assembly of components, and 7 wiring together their required and provided interfaces.
When 6 you use this definition, components appear 5 to be all about Inversion Of Control.
Looking at the .NET framework 4 for an example, the IComponent
interface indeed provides 3 IComponent.Site.GetService to achieve inversion of control through 2 the service provider pattern. A more light-weight 1 alternative is dependency injection.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.