Book a Demo

Author Topic: Large class diagrams  (Read 7253 times)

jd

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Large class diagrams
« on: January 26, 2007, 10:19:22 am »
Is there a way to organize large class diagrams into smaller mode managable class diagrams?

Say for instance that I create a package that has 26 classes denoted A to Z. Class A uses classes B-Z through object composition. I want classes B-Z to have
their own class diagrams.

Now on the class diagram for A I want to show classes B-Z as being used through composition but not have the class diagrams themselves.

Is this possible to do or is this be done with a component
diagram?

The sample eap project only has small class diagrams.


Any help would be greatly appreciated

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Large class diagrams
« Reply #1 on: January 26, 2007, 03:08:46 pm »
Quote
The sample EAP project only has small class diagrams.   ;)

Ah... yes grasshopper, but the forum has many posts.  Did you try a search before posting?
Quote
Is there a way to organize large class diagrams into smaller mode manageable class diagrams?
yes, but you will need to get your head around EA's UI (Unique Interface) - sit and be enlightened.
Quote
Say for instance that I create a package that has 26 classes denoted A to Z. Class A uses classes B-Z through object composition. I want classes B-Z to have their own class diagrams.

Now on the class diagram for A I want to show classes B-Z as being used through composition but not have the class diagrams themselves.

So if we understand you correctly, Class A is a composite (because it is is composed) and B-Z are not.  (It actually doesn't matter whether they are or not, but if they aren't it makes the absurdity of the interface that much more delicious...)   :D

Now as I understand it further, you want to be able to get to B, or H, or Q ...Z's Class diagram from the main class diagram - otherwise, grasshopper, you would not have a problem - that's what the browser is for.

Assuming that this is so...

Right click Class A and look for Context Menu|Advanced>Composite Element.  Don't touch it!  However, recall that Class A is the composite.

Draw your Composition relationship between Class A and Class B.  (A word to the wise, don't use the EA Composition Tool, use an Association and set the ends - search the forums to find out why)

Now take Class B and right click it...  Look for the same Menu option - remembering this is NOT the composite Class and set it!   ::)  What will happen is that a diagram will be created with the name Class B and a link from the Class B shape to the diagram.  There will also be a small (chain) link icon placed on the bottom right of the Class B shape, to indicate this property.  When you see this icon, you can double-click the shape and it will take you to the linked diagram.

Organisation into a traversable hierarchy...

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

jd

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Large class diagrams
« Reply #2 on: January 29, 2007, 09:22:40 am »
Quote
Ah... yes grasshopper, but the forum has many posts.  Did you try a search before posting?
yes, but you will need to get your head around EA's UI (Unique Interface) - sit and be enlightened.
So if we understand you correctly, Class A is a composite (because it is is composed) and B-Z are not.  (It actually doesn't matter whether they are or not, but if they aren't it makes the absurdity of the interface that much more delicious...)   :D

Now as I understand it further, you want to be able to get to B, or H, or Q ...Z's Class diagram from the main class diagram - otherwise, grasshopper, you would not have a problem - that's what the browser is for.

Assuming that this is so...

Right click Class A and look for Context Menu|Advanced>Composite Element.  Don't touch it!  However, recall that Class A is the composite.

Draw your Composition relationship between Class A and Class B.  (A word to the wise, don't use the EA Composition Tool, use an Association and set the ends - search the forums to find out why)

Now take Class B and right click it...  Look for the same Menu option - remembering this is NOT the composite Class and set it!   ::)  What will happen is that a diagram will be created with the name Class B and a link from the Class B shape to the diagram.  There will also be a small (chain) link icon placed on the bottom right of the Class B shape, to indicate this property.  When you see this icon, you can double-click the shape and it will take you to the linked diagram.

Organisation into a traversable hierarchy...

HTH,
Paolo



Paolo,

You state

"A word to the wise, don't use the EA Composition Tool, use an Association and set the ends - search the forums to find out why"

I am assuming this is why?

http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=UMLPRO;action=display;num=1118175557;start=2#2%22

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Large class diagrams
« Reply #3 on: January 29, 2007, 11:11:46 am »
Quote
Paolo,

You state

"A word to the wise, don't use the EA Composition Tool, use an Association and set the ends - search the forums to find out why"

I am assuming this is why?

http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=UMLPRO;action=display;num=1118175557;start=2#2%22
Yes jd,  

although, as you saw, the posting is now quite old.  Since I haven't used the EA aggregation since that time (and indeed have had to rectify models where others have inadvertently used it), I can't vouch whether the Sparxian have fixed some of the more glaring problems.

Certainly, you get less problems if you avoid it.  After all, EA does so itself - somewhere else I observe that when EA reverse engineers code it hasn't seen before, it creates Aggregate Associations.

Here in Western Australia, we used to have a racing car driver called Stan Starcevitch - who used to "flog" used cars...  His catch cry was...  "I wouldn't approve a car I wouldn't drive meself!"  Well, if EA won't endorse it, neither will I... ;)

Since that time, we've asked Sparx to add an option to have those tools draw the UML versions rather than the EA versions but so far no luck.  Feel free to add your voice or not...

HTH,
Paolo
BTW: If you do decide to use the EA aggregation don't forget to check out the operation of the Tools|Options|Links|[  ] Draw Aggregations Reversed checkbox.

Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

jd

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Large class diagrams
« Reply #4 on: January 29, 2007, 01:23:30 pm »
Thanks Paolo,

This leads me to another question;

When I create class A and my composite controls B-Z,
and generate the C++ code it makes B-Z object pointers
within class A what if they are just contained classes?

I created some sample C++ code that has a main class
with one contained class. I then reverse engineered this
sample code using EA. The class diagrams generated by EA
are not what I expect. It draws an arrow (not filled) from
the source class to the target class and adds the member variable name from the source class as the target role.

Is class containment modeled different then composition?

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Large class diagrams
« Reply #5 on: January 29, 2007, 01:49:22 pm »
Quote
Thanks Paolo,
 
This leads me to another question;
[size=13][SNIP][/size]
Is class containment modeled different than composition?
Most assuredly...  Structural containment is commonly known as nesting (and is currently depicted in EA as an element below and to the right of another in the browser).  On the diagram, the element naming reflects the containment.  UML provides an alternate rendering (See: [size=13]UML 2.1 Superstructure (interim)[/size] Specification - Section 7.3.37 Package (from Kernel), Figure 7.63 - Examples of a package with members) for use on diagrams.  You can find the nesting connector in the toolbox as the line with a circled cross (+)-------

I believe there are issues with EA's implementation of the nesting connector.  (Search for it in the forum)  I'm currently working on a redux of the nesting connector and I hope to put something out shortly.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

jd

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Large class diagrams
« Reply #6 on: January 30, 2007, 11:26:06 am »
Paolo,

I have one more question in regards to my previous example. Again I have classes A - Z, classes B through Z are contained within class A through object composition.

When I create the composite element for class B it creates a new composite structure diagram. This is not really what I want, class B is not a composite class per say, it is it's own class contained within class A. So when I add a class diagram it calls it ClassB::Class1. ???

I thought that if I performed the above it would create a class diagram for Class B. :o

Maybe the correct procedure for what I am trying to accomplish is creating an object instance of class B on class A's class diagram. But when I do this I cannot access class B by double clicking on object B's object intance icon.

In effect what I am trying to do is have seperate class diagrams for all the classes (B-Z), show them on A but not have all the attributes and operations showing.

This has to be possible doesn't it? Is this supposed to be done at the component view level?

??? ??? ???

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Large class diagrams
« Reply #7 on: January 30, 2007, 01:50:52 pm »
Quote
When I create the composite element for class B it creates a new composite structure diagram. This is not really what I want, class B is not a composite class per say, it is it's own class contained within class A. So when I add a class diagram it calls it ClassB::Class1. ???

I thought that if I performed the above it would create a class diagram for Class B. :o

If you want a child diagram type other than the default, create it before executing the "Composite Element" command. The command only creates the default diagram if there isn't an existing child diagram to link to.

There are plans to improve this command, adding a dialog that allows you to choose which from a number of child diagrams to link to or allowing you to create a child diagram of your choice. I have no idea how that is progressing, if at all.
The Sparx Team
[email protected]

jd

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Large class diagrams
« Reply #8 on: January 30, 2007, 03:01:19 pm »
KP,

Thanks for the information but this doesn't resolve the problem.

Let me break this down into something real simple.

Say for instance I have two classes, Class A and Class B each of which has it's own class diagram. Class A has an attribute (member variable) of type Class B. I want to show the composite relationship of A to B on class A's class diagram.

Are you supposed paste an instance of object B into A's class diagram or a simple link? I don't really want to display the attributes and operations of class B on A's class diagram. I just want to show the relationship and have the ability to traverse through the classes.


Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Large class diagrams
« Reply #9 on: January 31, 2007, 03:59:47 am »
I think I've got a clearer picture of what the problem might be for you.

First, however, let me ask some questions...

You are an EA newbie, are you also a UML newbie?

Are you attempting to design (from scratch) using EA or have you reverse engineered some existing code?

If you haven't reverse engineered any code, do you have a code snippet that illustrates the composition you are trying to model?  If you have such a snippet, have you tried reverse engineering to see what EA does with it?

Pardon the questions, but once we have the answers to them, we should be able to put this "to bed" for you...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

jd

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Large class diagrams
« Reply #10 on: January 31, 2007, 07:52:49 am »
Paolo,

To answer your questions;

- You are an EA newbie, are you also a UML newbie?
Yes and Yes

- Are you attempting to design (from scratch) using EA or have you reverse engineered some existing code?

I have done both, but I am trying to model a new software project.


- If you haven't reverse engineered any code, do you have a code snippet that illustrates the composition you are trying to model?  If you have such a snippet, have you tried reverse engineering to see what EA does with it?

Yes I have reverse engineered some code that implements the features I have described. Reverse engineering the code has taught me more than the EA online help (which is pretty weak).

With this being said, when I reverse engineer my top level class it places all other class diagrams in the same logical view. As you can imagine if this were a really complex software system with hundreds (if not thousands) of classes the logical view would be very unmanageable. It would be nice to move some of the other class diagrams into their own class diagrams and reference them from the top level class diagram.

The EA sample project implements a trivial little class diagram, obviously this isn't a real world situation.

Thanks,

JD

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Large class diagrams
« Reply #11 on: January 31, 2007, 09:09:05 am »
Quote
[size=13][SNIP][/size]
With this being said, when I reverse engineer my top level class it places all other class diagrams in the same logical view. As you can imagine if this were a really complex software system with hundreds (if not thousands) of classes the logical view would be very unmanageable. It would be nice to move some of the other class diagrams into their own class diagrams and reference them from the top level class diagram.
JD, Sorry to be pedantic - but the devil is in the detail... :)

Your point here is that the RE placed all the class diagrams at the same level of nesting.  But in your responses, I'm sometimes a bit confused about your use of the term diagram.

Do you always mean: A graphical presentation of a collection of model elements, most often rendered as a connected graph of arcs (relationships) and vertices (other model elements). UML supports the following diagrams: class diagram etc.  Sometimes I think you use the term diagram to mean the rectangular notation where each rectangle is the rendering of a class' metadata.

If I had a small code snippet with classes A, B & C, where A is a composite of  B and C; I would expect EA to reverse engineer that to 1 diagram with 3 elements, A B and C.  A and B would be connected by a line (with adornments) and likewise A & C.

Does my terminology agree with how you would describe EA's behaviour - or would you say that the class diagram for A contains two other diagrams for B & C?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

jd

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Large class diagrams
« Reply #12 on: January 31, 2007, 09:56:46 am »
Paolo,

What you state;

- Sometimes I think you use the term diagram to mean the rectangular notation where each rectangle is the rendering of a class' metadata.

Yes this is correct


- I would expect EA to reverse engineer that to 1 diagram with 3 elements, A B and C.  A and B would be connected by a line (with adornments) and likewise A & C.



This is exactly what I get when I reverse engineer the code. Now how would one move the B and C class diagrams to their own logical views and reference them from class A's logical view?


Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Large class diagrams
« Reply #13 on: January 31, 2007, 05:36:32 pm »
Quote
Paolo,

What you state;

- Sometimes I think you use the term diagram to mean the rectangular notation where each rectangle is the rendering of a class' metadata.

Yes this is correct
Ah... I suspected that from your very first post, but I was hoping I would not have to explicitly ask...  However, it is better to ask than suspect.  Your use of diagram in this way is part of the reason it has taken us (Sparxian KP and myself) so long to (hopefully) resolve the issue for you.

If you look at the definition of the term diagram (taken from EA's Help file - but good enough for our purposes) the diagram is the frame in which there are three shapes (or vertexes - vertices for the Latin scholars) - Class A, Class B and Class C.

A diagram is just a collection of shapes and lines (Vertexes and Edges or Nodes and Arcs or any mixture of the respective terms).  I think what you call a Logical View is what the rest of us call a diagram.  The notion that there is a diagram for Class A is not strictly correct.  There can be a diagram that contains shape A and other shapes, or there can be a diagram that is somehow linked to shape A and tells you something about shape A without having an explicit reference to shape A.  In other words, you decide the semantic content (meaning) of a diagram.  EA provides the ability to associate one diagram with a shape so that if you double click the shape on any other diagram, it will open the associated diagram.  This is the functionality I discussed in my first reply to you.  Since you are a UML newbie, the irony and humour in the explanation may have made you a bit more confused - but just as you were using the term diagram in a rather unique way, Sparx also uses terms in unique ways.  If you want to associate a diagram with a shape, you need to use the "Composite Element" functionality even if the shape you are associating with is not actually a composite element.

So, to summarise, EA creates diagrams that can contain shapes and lines.  Some of those shapes can be classes.  A shape can have an associated diagram so that if you double-click the shape, the associated diagram will be opened by EA.
Quote
- I would expect EA to reverse engineer that to 1 diagram with 3 elements, A B and C.  A and B would be connected by a line (with adornments) and likewise A & C.

This is exactly what I get when I reverse engineer the code. Now how would one move the B and C class diagrams to their own logical views and reference them from class A's logical view?
Hopefully, you now understand that from a UML viewpoint, when we reverse engineer the A, B  and C classes above, you should get the diagram I described and you actually got.

If you are forward engineering, you control which diagrams get created and what their content is.  If you reverse engineer, depending upon the options you select, EA will automatically create some diagrams on a per namespace or per directory basis.  As you suggest, if there are a lot of classes in these containers, than there will be a lot of classes in the diagrams.

Normally, users create their own diagrams and ignore the ones created by EA.  As you'll read in many posts on the site, the model is a communication mechanism, so you need to decide what each diagram is trying to convey and place the appropriate shapes and lines to do that.

To get back to your original post,  it is normal practice for a diagram to show a class and its associated classes.  Thus, you'd get the diagram you got from reverse engineering - which could be said to be Class A and it's associated classes:  Class B and Class C.  You could construct another diagram call it Class C which would show Class C and it's associated classes:  In our example, this would be class A - there's not direct connection to B.  If you create a new diagram and drag class C onto it (from the browser), you will have a diagram with a single class shape (Class C).  If you then drag Class A onto it, EA will automatically add the Composition Association between A and C for you!.

Now, it will occur to you that this is quite tedious for large diagrams or well connected classes.  And any way - how do you know which classes are connected to which in a large model?  Well, EA knows!  Create a third diagram, This time drag Class B onto it.  Select it, and then use <Context Menu>|Add>Insert Related Elements - EA will automatically add to the diagram (using the default option) all the stuff that is connected to Class B.  This is how most users create diagrams from existing information.  You can then edit the diagram to show only what you want to show.

So does that help explain what's going on?
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!