Please, could anybody explain the difference between Model, Package, Subsystem in a class diagram?
Referring to the the UML Superstructure Specs, I found the following:
A model captures a view of a system. It is an abstraction of the system, with a certain purpose. This purpose determines what is to be included in the model and what is irrelevant. Thus the model completely describes those aspects of the system that are relevant to the purpose of the model, at the appropriate level of detail.
A package is used to group elements, and provides a namespace for the grouped elements.
C: Standard Stereotypes: Subsystem
A unit of hierarchical decomposition for large systems. A subsystem is commonly instantiated indirectly. Definitions of subsystems vary widely among domains and methods, and it is expected that domain and method profiles will specialize this construct. A subsystem may be defined to have specification and realization elements. See also: «specification» and «realization».
For me, to differentiate between the three, the model is the largest component you can describe – it is describing your system as a whole. Then a subsystem is a smaller system within your system. Finally, a package is a collection of elements with a namespace. From my understanding of the definition above, a subsystem is instantiated as a whole so therein lies its difference with a package since packages are simply a meaningful grouping of elements, which can be instantiated individually.
Thanks for your reply!
For C++ code generation, must I pay attention for choosing the right element of those 3 ones? I want to model in a way to get the most out of it when generating C++ sources.
For C++ code generation, I would pay close attention to how you model your packages as they will likely dictate your code’s namespaces. Other than that, I believe the rest are conceptual.
Are those namespace generation rules written somewhere?
As far as I know (I may be wrong), there isn’t a standard on generating code from UML as it can be interpreted in different ways given certain contexts. In the case of namespaces, to me, it makes sense that they correlate with UML packages since even the official specs explicitly mention “namespace” when describing a UML package.