Showing posts with label UML. Show all posts
Showing posts with label UML. Show all posts

Sunday, January 16, 2011

UML : Class Diagrams- A step by step tutorial with examples.

Class diagrams are the most often used UML diagrams.
The purpose of a class diagram is to specify the structural makeup of the system. 
This includes class relationships and the attributes and behaviors associated with each class. 
Class diagrams are remarkable at illustrating inheritance and composite relationships. 
To use class diagrams as an effective communication tool, developers must have a consistent 
understanding of how the elements appearing  on a class diagram are translated to Java. 

Lets Detail it out :
The elements
The following items represent the elements of a class diagram and their corresponding representation in Java. 
I will list the name of the element, followed by a short code snippet and a picture representing what 
that element would look like on a class diagram.
 A short description of the element will conclude each section.

Class
A class (Figure A) is a blueprint for an object, containing three compartments. 
The first represents the name of the class as defined in Java. The second represents the attributes. 
The third compartment represents methods on the class.Attributes and operations can be preceded
 with a visibility adornment. 
A plus sign (+) indicates public visibility. A minus sign (-) denotes private visibility. 
A pound sign (#) denotes protected visibility. 
Omission of this visibility adornment denotes package-level visibility. 
If an attribute or operation is underlined, this indicates that it is static.
 An operation may also list the parameters it accepts, as well as the return type, 
as seen in the Java section in Figure A.

Figure A


Package
Packages (Figure B) are general-purpose grouping mechanisms. A package in UML translates directly into a package in Java. In Java, a package can contain other packages, classes, or both. When modeling, you'll typically have logical packages that serve primarily to organise your model. You'll also have physical packages that translate directly into Java packages within your system. Packages have a name that uniquely identifies the package.


Figure B

Lets understand more...

Saturday, January 15, 2011

UML : StateChart Diagrams

StateChart Diagram

This is a concept in Object Oriented Software Engineering, which is used to describe the behavior of the system.

State diagrams require that the system described is composed of a finite number of states; sometimes.

The below is an state chart diagram of  An Airline reservation system. I hope this helps people to solve their doubt about State Chart Diagram.


UML : Interaction Diagrams

Interaction Diagrams

  • An interaction diagram is a graphical representation of how objects interact with one another in a scenario. 
  • They capture the behavior of a single use case,showing the pattern of interaction among objects. 
  • Objects communicate in an interaction diagram by sending messages. 
  • Sending a message typically corresponds to invoking a method or function, where the message name is the name of the method. 
  • A message may carry data as parameters being passed.


UML provides two forms of interaction diagrams :
A. Sequence diagrams
B. Collaboration diagrams

Since we have only sequence diagram here are some tips and some information about sequence diagram

Sequence Diagram shows an interaction arranged in a time sequence. It has two dimensions :

1.Vertical Dimension representing time
2.Horizontal Dimension representing different objects.

 Sequence Diagram : Objects

  • An object is shown as a box of at the top of the dashed vertical line also know as the lifeline of the object.
  • It represents the object’s existence during the interaction. 


Sequence Diagram : Message 
  • An interaction is a set of messages exchanged among a set of objects to accomplish a particular purpose within a given context (such as a collaboration).
  • A message is a conveyance of information from one object to one or more other objects with the expectation that activitywill ensue, in the form of an action.
  • A message can be either a signal or a call. 
  • Within a process or a thread, messages are ordered in sequence by time.
 MESSAGE NOTATION :



Sequence Diagram : Recursion And Delegation



An Example:  Sequence Diagram of An Airline Reservation Syatem


subversion video