Introduction to UML
Part II

By Michael Gold

 

In our last article we gave an introduction to the most useful diagrams in UML class, state, activity, use case and sequence diagrams. In this article we will tell you a little bit about some of the remaining diagrams which also have there place in the designers arsenal, so we'll mention them.

 

The Collaboration Diagram

The UML notation on this diagram makes it seem that this is not one diagram, but the composite of several different diagrams that were all lumped together and labeled "collaboration diagram".  In the UML documentation you have parameterized collaboration diagrams, message flow collaboration diagrams.  It seems to me that this particular diagram structure was probably a battle over the "three amigos" on how the heck to make it seem like it could be thrown in.  After all,  you had sequence diagrams coming from the Rumbaugh OMT camp, and collaboration diagrams coming from the Booch camp.  The message flow collaboration diagram in many ways describes the same information as the sequence diagram.  It is argued in the UML notation, that sequence diagrams show time flow of messages and collaboration diagram gives you a detailed view of relationships between objects and message passage.  But relationships can already be seen in the class diagram, and timing of messages are labeled as sequences and subsequences in the collaboration diagram, so there are many overlaps here.  Anyway, that said, let's talk about message flow collaboration diagrams.  In our last article we had an example of a sequence diagram shown below:

Fig 1.

 

The equivalent collaboration diagram would look like below:

 

Fig 2.

 

The UML 1.3 Notation says the boxes represent the roles and the solid lines are the association paths representing association roles. I think that it is easier, though,  to think of the boxes as instances of classes and the solid lines as interactions, just like the sequence diagram above.  Each # on the interaction represents the order of the messages being passed.  This is much easier to see on a sequence diagram because you just look down the graph vertically and you can see the time sequence.  The sub numbering tells you something about the scope of the messages passed.  In this example, Deposit (numbered 1),  calls MyBank.ValidateAccount (numbered 1.1). In an implementation In C++ this might look something like this:

void Customer::Deposit() {
  MyAccount.ValidateAccount();
}

As you can see, ValidateAccount is in the scope of the Deposit method in Customer.  Therefore it gets sub numbering. If ValidateAccount called a method  AccessDatabase to an Object called MyDatabase,  then AccessDatabase would get the sub numbering 1.1.1 as shown below:

Fig 3.

In the boxes, the colon is used just like in the sequence diagram.  The instance name appears before the colon and the class name after the colon.  You don't have to specify both the class name and the instance name, but you must supply the colon in order to see whether you are talking about an instance or a class.

Collaborations and patterns

One of the great design paradigms that has caught wind during the last few years is the concept of using patterns.  Not that this concept hasn't been around forever, but it recently has been adopted strongly by the object-oriented community egged on by the book "Design Patterns"  by Gamma.  Because of Patterns huge popularity,  the UML designers have eagerly added it to the UML notation as part of collaboration diagrams. The UML people have decided to call a pattern, "a parameterized collaboration).  This is symbolized as the dotted oval as shown below in our example flyweight pattern.  A flyweight is an object that is shared so that it can be used in multiple contexts.  The client object is responsible for supplying context information to the flyweight.   The example given in the gamma book is a document (the client) has information about font, color, and position of a character. Character, the flyweight keeps the character code information, but when it draws itself, it gets the shared information about font and color from the client. If the context information changes, it uses this information to draw itself differently.  The diagram below shows the parameters of the pattern in the rectangle above the oval.  The pattern structure is contained within the oval.

 

Fig 4. - Flyweight Pattern

The template parameters of the pattern can be "bound" by using dependency relationships:

Fig 5.

In our example,  the Client of the flyweight pattern is shown bound to the document (which supplies context information).  The flyweight is bound to the character object which is shared by different documents.

 

The Component Diagram

The component diagram is a UML attempt at showing the components used in your system.  Components can be quite complex, as we know from developing with ActiveX, JavaBeans and more.  Since components seem to be coming an extremely important part of doing development (and who really wants to reinvent the wheel),  I suspect this model will get more complex in nature. For now, it's quite simple.  A component is represented as below:

Fig 6.

Our simple example is a ListBox component with the property  SelectedIndex and the method AddString.  SelectIndex and  AddString are interfaces on the component.  They are the means in which the user manipulates or retrieves information from the component. In most IDE's these interfaces show up in fancy property windows in which the user can work with the interfaces. In our example, SelectedIndex would be the index of the item when a user selects a string in the listbox.  The AddString method, allows the programmer to supply a string to add to the listbox.  Most listbox components have many more methods and properties than this, but we have chosen only a few for our example. Also an intricate part of  the component diagram, is the Node.  The Node is the domain in which the physical components can be found:

Fig 7.

Above we see two components ListBox and TextBox located on the Node Mike's Machine. Note, Mike's Machine is type PC as seen with the colon separator.  Dependency relationships can be used to indicate when one component talks to the interface of another:

Fig 8.

The dependency relationship connecting our database component on the Administrator's machine to the TextBox component on Mike's machine, shows us the interface TextString on the TextBox component is accessed by the db Component.  Note also in this diagram that our component names are underlined.  The underline indicates that the components are instances or each component running inside the node. Also again, the colon is used consistently to separate the component type (right) from the component instance (left). The communicates in the << >> is called a stereotype. We will conclude this article with a discussion of stereotypes.

Stereotypes

UML includes a notation called stereotypes and they can be found on all diagrams.  Stereotypes are displayed as text inside a double less than, greater than, bracket.  i.e.  <<communicates>>.   Stereotypes were invented by the designers of UML as a way to give different UML shapes more specialized roles to describe a diagram component.  An example of a stereotype for Operations might be for all the operations such as getDate, getName, getFoo called  <<accessors>>.  <<accessors>> are a specialized operation for retrieval.  Stereotypes are nice, because you don't have to keep inventing new shapes for things that already encompass the general case for something you need to describe.  Component shapes can have stereotypes such as  <<dll>, <<executable>>, <<file>>, <<library>>, <<table>>, <<java component>>, <<ActiveX>>..   Stereotypes are quite flexible and give the designer a very broad way of describing UML notation types.  They also helped the UML designers to extend the UML notation without making it overly more complex.

This concludes Part II of our UML discussion.  In Part III we will touch upon  how UML relates directly to code so that a programmer can take a UML design and use it to benefit them in real world situations.

Michael Gold is President of MicroGOLD Software Inc. 
a company that sells UML design tools.  All diagrams in
 this article were created using MicroGOLD Software’s WithClass 99.

 Email: mike@microgold.com

URL: http://www.microgold.com

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

cialis link tw886to generic cialis prices best price viagra cialis cialis attorney cincinnati cialis lowest price generic cialis trial packs black buy casino cialis diet followup gambling health jack phentermine poker post viagra cialis and bodybuilding cialis medication free generic cialis samples black buy casino cialis diet followup gambling jack online order phentermine poker post viagra cialis black box cialis message boards generic cialis american express apotheke cialis cialis and levitra and viagra and generic cialis muscle ache generic cialis hong kong archive blog cialis inurl cialis and levitra cialis line mexico does cialis work for women allowed black buy casino cialis diet holdem jack online order phentermine poker tag texas viagra xhtml cialis and multiple coitus cialis no prescription generic cialis price best for premature ejaculation viagra cialis levitra cialis and women cialis link liracrogreekbostoncom generic cialis allowed casino cialis diet phentermine poker tag viagra xhtml cialis add url cialis lawyer ohio experience cialis without ed allowed cialis phentermine tag viagra xhtml cialis back pain cialis online order how to get free cialis sample black buy casino cialis diet gambling jack order phentermine poker tag viagra xhtml cialis discount cialis maximum dose international order for generic cialis blogid buy casino cialis generic inurl order phentermine poker viagra cialis and blood pressure cialis mexico is cialis for me blogid buy casino cialis inurl phentermine poker viagra cialis and grapefruit cialis levitra viagra discount cialis best buy cialis generic ciales rock climbing cialis international shipping does cialis or levitra work best for diabetics allowed black buy casino cialis diet health jack phentermine poker sex tag title viagra xhtml cheap viagra cialis cialis lawyer cincinnati effectiveness of cialis reported allowed black casino cialis diet gambling jack phentermine poker tag viagra xhtml cheapest and cialis and generic and lowest price cialis injury attorney ohio compare levitra and cialis add cialis link suggest catholic cult and cialis cialis lcos lily online free cialis approval cialis fda cialis and early ejaculation cialis levitra viagra interaction generic cialis cheap free shipping free consultation articles on cialis cheapest cialis cialis injury lawyer columbus generic cialis international shipping buy cheapest cialis cialis compare levitra viagra cialis line prescription generic cialis next day black buy casino cheap cialis diet followup gambling health jack online order phentermine poker post viagra ciales cialis international shipping contact number cialis add buy cialis url cialis 20mg tablet cialis liquid how long does cialis take to work black buy casino cialis diet gambling health jack phentermine poker tag viagra xhtml cialis and alcohol cialis lawyer cleveland effectiveness viagra cialis levitra allowed casino cialis phentermine tag viagra xhtml cheapest cialis free samples cialis levitra versus versus viagra fda pharmaceutical testing trials cialis anti cialis impotence cheapest cialis price cialis injury attorney columbus compare viagra cialis and levitra add cialis site cheapest cialis with no perscription cialis injury lawyer cleveland compare viagra to cialis achat ligne cialis cheap cialis link suggest cialis impotence drug cialis with no prescription add buy cialis site canada cialis online cialis information prescribing cialis viagra taken together where can i buy cialis online black buy casino cialis diet followup gambling jack order phentermine poker post viagra cialis blindness cialis link suggest diabeties viagra cialis levitra allowed black buy casino cialis diet gambling jack order phentermine poker tag viagra xhtml cheap cialis online cialis generic tadalafil cialis without prescriptions add cialis generic link cialis and levitra taken together cialis information clinical trial testing cialis for high blood preasure add cialis link online canada generic cialis cialis germany cialis strength time line to buy without prescription cialis or levitra in detrit area buy cialis submit=buy cialis cialis drug interaction cialis online liquid cialis black buy casino cialis diet followup gambling jack low online order phentermine poker viagra cialis attorney cleveland cialis injury lawyer cincinnati cialis vs viagra .. can you take cialis with viagra cialis home page cialis western open ticket add buy cialis link canada cialis generic cialis generic online cialis uprima viagra value pharmaceuticals cialis buy cialis order cialis eli lilly cialis pharmacy natural supplement like cialis