• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Class Diagram and Object Diagram

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is diff between Class Diagram and Object Diagram
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Err. One shows classes, and the other shows objects.
They really are very different. About all they have in common is that they both use boxes and lines. Is there anything in particular you are confused about ?
 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if i have a class diagram then do i need Object diagram.
If my class specifices all the relationship between classes, its attributes, methods, then what is the use of object diagram
It may be used to show relationships between objects, is that the only use or there is something more
Thanks
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if i have a class diagram then do i need Object diagram.
Maybe. It all depends what information you wish to communicate, and to whom. Remember that diagrams are all about communication with people, so use whatever diagrams best express what you are trying to communicate.
If my class specifices all the relationship between classes, its attributes, methods, then what is the use of object diagram
One major feature which distinguishes an "object-oriented" design from a simply procedural design using classes, is that it can have multiple instances of each class. The purpose of an object diagram is to help communicate information about how these different objects interact.
Take the simple example of a linked list. Typically each "node" on the list will be of the same class as each of the others. If you just draw a class diagram there is no way to indicate that each node holds a reference to the next node in the list. All you can show in a class diagram is that an object of class Node can hold a reference to another object of class Node. This says nothing about how Node objects are actually used.
It may be used to show relationships between objects, is that the only use or there is something more.
I don't really know what else you might want to do with an object diagram. I guess you could add markup normally found in 'collaboration' or 'sequence' diagrams if you want to. Again, it all depends what you are trying to communicate.
Finally, here's something to think about; ask yourself the converse question: "if i have an object diagram then do i need a class diagram?" What information is in your class diagram which makes it so important to you?
 
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can Object diagrams also show life histories of an Entity or Class ?
regards
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not entirely sure what you are asking here.
An object diagram is essentially a static (example or "snapshot") view of a system. "life histories" implies som sort of time element which would normally be more suited to something like a sequence diagram.
As for showing classes, I guess you could, if you reckon that treating classes as objects themselves helps you get your message across. Several O-O languages treat each class as an instance of some sort of special "meta-class", so there is a precedent. I can't help thinking that this is way more likely to complicate and confuse your diagram than help explain a point, though.
Can you offer any more detail on why you would wish to show classes on an object diagram?
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Entity
1 a : BEING, EXISTENCE; especially : independent, separate, or self-contained existence b : the existence of a thing as contrasted with its attributes
2 : something that has separate and distinct existence and objective or conceptual reality

Class
3 : a group, set, or kind sharing common attributes: as a : a major category in biological taxonomy ranking above the order and below the phylum or division b : a collection of adjacent and discrete or continuous values of a random variable c : SET 21


I took *OBJECT* and entity to mean the same thing. A class is a conceptual reality, while object is a single instantiation of that reality.
The bit I find difficult is to say which one is static - class or object. You say, object. Why ?
If you take another snapshot a few hours later, the object could still be the same object but may have changed in some way, that now it's another object of a different class.
I think this is possible.
Actually , if Object Diagrams shows only relationships between objects, Frank, I think you are right that including any time element complicates the diagram.
I thought if you were modelling Agilely , you'd want to combine some information into one model.
But I think it's supposed to work the other way.
i.e the models are simple enough to communicate just barely what is needed.
Use class diagrams to :

show the classes of the system, their interrelationships (including inheritance, aggregation, and association), and the operations and attributes of the classes.


Use object diagrams to show relationships among objects. I think they are particularly useful for recursive relationships.
eg: Employee manages and is managed by Employee

regards
[ July 15, 2003: Message edited by: HS Thomas ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*Both* class and object diagrams are static in the sense that they don't contain an element of chronological order or the like.
On the other hand, a class diagram is also showing the "static structure" of the system, which is more or less determined at compile time. Object diagrams are more "dynamic" in the sense that they show a snapshot of the actually existing dependencies between objects in the system at some time (whereas class diagrams are merely showing the potential of such dependencies).
You could say that object diagrams are "instances" of class diagrams. Class diagrams could be seen as "templates" for possible dependencies in a system, whereas object diagrams show the actual dependencies in a specific situation.
Well, did that help at all?
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, thanks Illja. That explanation does help in distinguishing between static and dynamic behaviour of objects.
Are Object Diagrams used a lot ? Are they different from Object Role Models ?
regards
[ July 15, 2003: Message edited by: HS Thomas ]
 
bacon. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic