Two Laptop Bag*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Class Diagram UML diagram Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Class Diagram UML diagram" Watch "Class Diagram UML diagram" New topic
Author

Class Diagram UML diagram

Genie mani
Greenhorn

Joined: Feb 10, 2003
Posts: 10
I need someone to guide me develop UML diagram for the situation presented below.
1) class diag, seq. dia...
I have a class(A) which
1) reading MQ message
2) reads from the database for getting some results for verification
3) Read a property file
4) sends a part of the message to another class and gets a resultant message from that class
5) finally passes the resultant message to another class (B) for further process.
(B) class now chooses to call
1) out of 6 classes any one class based on some identification from
the message received from (A)
another question
1) when i am instatiating another class in one class mentioned above
how will be presented in the class diagram.
thnx in advance
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Hi, don't panic! Sounds like you have a good idea of major classes and messages (method calls) between them so you're in a good place.
Try an Object Interaction Diagram first - bubbles for objects, arrows for messages. I start with bubbles in a big circle for fewer line routing problems. Draw an arrow for each message, label it with a sequence number and description. If object A calls B twice, you can make two arrows or one arrow with two labels stacked up.
Play with this a while. Run various success/failure scenarios. Get a feel for the flow of information and control. One thing I learned from my dad who taught college math for 32 years: use lots of paper! Make big diagrams. It's ok to throw it out and start over.
When I think I know what's going on pretty well, I usually switch to a sequence diagram. Technically these two diagrams contain exactly the same information and some tools can transform one into the other. I like sequence diagrams to show more detail and start to investigate the logic. I often switch to a graphical tool for this; sequence diagrams are a bit tougher in pencil & paper.
You asked about showing object creation. Some people do, some don't. You can often ignore it. Then again, if it makes you more comfortable to be explicit, go for it.
Neither diagram shows complex logic well. Like the choice between 6 objects. I think there is UML notation for "exclusive or" drawn across 6 arrows, but a simple comment would tell you the same thing. And if all 6 objects use the same abstract ancestor or interface, you can get away with just drawing the abstraction for now.
All that stuff is dynamic - runtime messages between classes. The class diagram is static dependencies and relationships. A lot of people like to make CRC cards - real 3x5 cards that list class, responsibility and collaborators. That's a neat way to physically handle your classes and get a different feel for them.
Now you're looking to see if the classes make sense. Do they do one thing well? Are there circular dependencies? Do they have the information they need to to their jobs? Now you can show the relationship of those 6 objects. Do they extend a common superclass? Implement a particular interface?
My biggest problem is staying at the appropriate level of abstraction. I always want to dig into too many details. Maybe you show a simple arrow from one object to an EJB but you know that's really: do JNDI lookup, get home object, get remote object, call the remote, marshall the data, and so on. On day one the simple arrow is plenty. All those details can go into their own diagram later.
I'd repeat that throw it out and start over bit again. Maybe try this twice and see if you get the same answers.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Genie mani
Greenhorn

Joined: Feb 10, 2003
Posts: 10
hey thanx Stan.. but what i need i a UML notation diagram for the above , i have already made a diag for the same but its a mixture of class diag as well from Chen diag( used to databse ) and not a proper UML one....
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Why do you care that it's proper UML? Whom are you doing it for?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Genie mani:
1) when i am instatiating another class in one class mentioned above how will be presented in the class diagram.

Not at all. A class diagram shows the static structure of your system, whereas instantiating a class is dynamic behaviour.
If you really need to depict those two together, you could mix the class diagram with another type, of course.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Here are some samples and tips on the Diagrams of UML 2. See if that's enough of a jump start to begin drawing.
It's important to know who your audience is. If you have to do some school work stick to rigorous UML, the more complex the better . If it's for a few colleagues, stick to the simplest options of the UML - nobody knows ALL the obscure decorations on the boxes and lines. If it's just for you, some boxes and arrows on a napkin may do.
I find it amusing that we are essentially a RUP shop, use a lot of Rational tools including Rose to draw UML diagrams, but we very rarely produce UML diagrams. We do a lot of lovely presentations for management in no particular notation at all, mixing 3D boxes with gradient colors for objects, computers, components, subsystems with arrows for data flow, control flow, dependency flying right and left.
Oh, I said "object interaction" which is now "communication". They keep changing the darned names. That one already changed once before.
[ June 06, 2003: Message edited by: Stan James ]
[ June 06, 2003: Message edited by: Stan James ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class Diagram UML diagram