Component diagram versus Class diagram?
Asked Answered
N

4

15

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?

Nival answered 30/6, 2013 at 11:48 Comment(0)
R
17

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 :-

enter image description here

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 :

enter image description here

I hope that I made myself clear.

Richardson answered 1/7, 2013 at 10:1 Comment(6)
In both cases I am talking about design I would like to see an example in: 1)How can class and package diagrams model logical design of software? 2)How can component diagram models implementation view?Nival
As you can see your implementation view (through component diagram)not reveal any implementation details?Nival
Logical design according to class perspective is an organisation of classes and their associations as you can see in my class diagram. Component diagrams model implementation view by just showing the implemented software components. As noted in other answers it shows less detailed view of the same class, just how they are implemented as software components.Richardson
In this example CUSTOMER AND ORDER are implemented in software as customer.java and order.java.It does not reveal any coding details, Somewhere it may and should contain interfaces(), but overall you can say it shows an abstract form of implementation.So, in short I tried my best to explain it to you, showing examples for a complete system would take so much space and would not count as a very good answer on this platform.If you wanna look for a more detailed diagram you can look it HERE --uml-diagrams.org/component-diagrams-examples.htmlRichardson
@ROHIT how did you convert the class diagram to the component diagram? Can you please send me the link to the guidelines that helped you to perform this conversion?Talbot
Your top diagram is, despite its title, not any kind of component diagram but simply a set of notes. You should correct that.Alage
R
5

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

Runty answered 30/6, 2013 at 11:58 Comment(1)
Thank you very much for clarifications @Anirudh ,Up vote for you :) Now,I would like to see an example(Last part of my question) in a class and component to be able to notice the correct application of the differenceNival
S
2

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.

Sirkin answered 30/6, 2013 at 11:56 Comment(1)
thanks @Loïc Faure-Lacroix .I updated my question .Does this make sense?Nival
S
1

A class model is the base for the component model:

  1. Software designers first design the logical structure specifying logical elements ("Classes"), their responsibilities ("Methods"), structure ("Properties") and relationships to other classes (Generalization, association etc.), regardless (at some extent) of the technology that will be used. This is the Class model

  2. Based on the class model, Software engineers specify the pieces of software ("Components") what they will write or otherwise purchase and the connections between them (integrations, depedencies etc.) in order to realize the designed Class model. This is the Component model.

  3. The Deployment model then depicts where the Components will be deployed on the hardware or virtual hardware.

Stoical answered 5/9, 2019 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.