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?

user2019510
  • 1,460
  • 5
  • 16
  • 29

4 Answers4

16

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.

0decimal0
  • 3,884
  • 2
  • 24
  • 39
  • 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? – user2019510 Jul 02 '13 at 19:18
  • As you can see your `implementation view` (through component diagram)not reveal any implementation details? – user2019510 Jul 02 '13 at 19:26
  • 1
    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. – 0decimal0 Jul 03 '13 at 01:53
  • 2
    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 --http://www.uml-diagrams.org/component-diagrams-examples.html – 0decimal0 Jul 03 '13 at 02:05
  • @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? – Sadiksha Gautam Jan 12 '15 at 20:59
  • 1
    Your top diagram is, despite its title, not any kind of component diagram but simply a set of notes. You should correct that. – qwerty_so Nov 03 '15 at 21:06
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

Anirudha
  • 32,393
  • 7
  • 68
  • 89
  • 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 difference – user2019510 Jun 30 '13 at 12:55
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.

Loïc Faure-Lacroix
  • 13,220
  • 6
  • 67
  • 99
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.

Hakim
  • 11
  • 2