class and package diagrams model logical design of software
component diagram models implementation view
Could you please clarify the above difference through a very short example?
The answer lies in your question itself. How do you think, a software is designed and a software is implemented?
In design, we develop blueprint for designing workable software. This blue print involves a model which can be translated into software, while implementation involves the conversion of that model into actual software i.e code.
Similarly, A component is generally bigger and more abstract than a class. While a class is a relatively low-level blueprint(design) for an object instance, a component might be a set of classes which together forms an encapsulated module(implementation) you then interface with. A component might even contain no classes at all!
Now, component diagrams don't show the actual code but the dependencies between the actual implemented software components (these components can be anything like executables,files,folders etc. As for example :-
As I have already discussed; Class diagram is UML structure diagram which shows structure of the designed system at the level of classes and interfaces, shows their features, constraints and relationships - associations, generalizations, dependencies, etc. example of a class diagram :
I hope that I made myself clear.
In UML component can do the same thing as class diagrams.
But the main difference is that components have bigger responsibilities than class
Kruchten developed the 4+1 view model to capture different parts of the system.Simply put,it helps you model different views(logical,physical,devlopment,process,use case) of the system
Each view captures a specific aspect of the system
Logical view describes what a system is made up of and how the parts interact
Implementation view also known as Developement view describes how system's parts are organized into modules and components
Habitually it can be seen as a more detailed diagram. The class diagram should have properties defined with implementation specific types such as.
Box
- cats: list<Cat>
+ getCat: Cat
+ addCat: void
The component is a less detailed view of the same thing. I don't remember how much detail is visible. As far as I remember, it could be the same thing as the class diagram without types.
The component diagram should be used to design the general idea of what you're trying to build. The class diagram could differ having more classes because the implementation requires classes that don't have to be present using the component diagram.
My words have to be taken with a grain of salt because I admittedly didn't draw diagrams for a while.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With