Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top