UML Introduction

Great software:

Great software is which satisfies customer needs, this will be the most highest important thing for any software. Here you can also see few important features of a great software.

  • It is flexible, reliable.
  • Easily maintainable.
  • Reusable.
  • Extendable.

What is UML?

  • UML stands for Unified Modeling Language
  • It is developed by Grady Booch, Ivan, James in 1997 at Rational Software.
  • UML is defined by OMG (Object Modeling Group)

Why we use UML:-

  • UML is a language focus on the conceptual and physical representation of a system.
  • The UML is more than just a collection of graphical symbols.
  • The UML identifies the specification of all the important Analysis, Design and Implementation decision that must be made in developing and deploying a software system.
  • Most dynamic way to write a system blueprint.

Definition:

UML is a unified modeling language for Visualizing, Specifying, Constructing and Documenting the artifacts of the Software Systems.

Visualizing:

A picture is worth of a thousand words; a graphical notation articulates and unambiguously communicates the overall view of the system.

Specifying:

UML allows to model precisely, unambiguously and completely, the system in question.

Constructing:

Models built with UML have a design specification to it, these are language independent and can be implemented in any programming language.

Documenting:

Each software project contributes a lot of documentation from the inception phase to the deliverables.

Building blocks of the UML:

The vocabulary of UML comprises three kinds of building blocks.

  1. Things- These are the abstractions that are first class citizens in a model.
  2. Relationships- Tie these things together.
  3. Diagrams- Group interesting Collection of things.

Things:

Class:

Collection of things which are having same property. It represent by rectangle.

A class contains 3 parts. Class name is the first part, it is divided in to two parts, Simple name - it is a textual string.

Ex: Customer, Employee.

Qualified Name- Name is a class name prefixed by the name of the package in which that class lives.

Ex: com.gk.uml: Course (i.e., package name :: class name)

Second part of the class is attribute. Attribute is a named property that describes the range of values that the instances of the property may hold. Attributes are like fields in java

Third part of the class is operations and operation is the implementation of a service that can be requested from any object of the class to effect behavior. Operations are like methods in java.

How to write UML to Java code?

UML to Java.jpg

Relationships:

We have four types of relationships

  1. Dependency
  2. Generalization
  3. Association
  4. Realization

1.Dependency:

  • A symantic relationship where a change in one thing (independent thing) causes a change in another thing (dependent thing).
  • It is denoted by “----› ”.(Arrow head points to the independent thing).
Ex:

In the below example shows percentage is dependent on marks

dependentonmarks.jpg

How to write UML to Java code?

UML2Javacode

2.Generalization:

  • A generalization is a association between a general classifier (called the super class/parent) and a more specific classifier (called the subclass/child).
  • In a generalization relationship from the child to parent, the child will inherit all the structure and behavior of the parent.
  • It is denoted by: arrow
  • It is ‘IS-A’ relationship
Ex: In the below example BankaccountAc is the super class and remaining two classes are child classes.
super&childclasses

How to write UML to Java code?

Uml 2 Java code

3.Association:

  • An association is a unified structural relationship that specifies that the objects of one class are connected to objects of another class.
  • It is denoted by This is bidirectional link.

How to write UML to Java code?

Uml to Java code

Multiplicity:

Multiplicity in an association determines the number of objects participating in the relationship.

Ex:-
multiplicity

How to read multiplicity in UML means

In the above example 1 company can contain 1 or many employees.

How to define multiplicity:

Start from company side and say 1 company (doesn't matter what is cardinality at company side) can have 1 or many employees, now place the result at employee side. Repeat same from employee side, 1 employee belongs to 1 company, now put the results at company side. That's it how simple it is to define multiplicity.

We can give the multiplicity in so many ways

i.e., 0…1( 0 to 1) , 0..*(0 or more) , 1..* (1 to many), 0…n (0 to n/n>1).

Association can divided into two special types Aggregation and Composition.

Aggregation:

  • A “entire/part ” association in which one class represents a larger things (whole),which consists of smaller things(parts) is called aggregation.
  • Aggregation represents a “HAS-A” relationship.
  • Represented by unfilled diamond at the entire end. Aggregation
  • Most important thing here is part can exist without whole. That is 'Tire' can exist without 'Car'. Part is independent whole.
Ex:
Aggregation

Composition: (CD → C for Deletion)

  • Composition is a same type of aggregation.
  • Composition specifies ownership and confident lifetime as part of the entire. This means that composition is must manage the creation and destruction of its parts since the parts cannot exist in their own.
  • A composite object will not exist without its components.
  • At any time , each given component object maybe part of only one composite.
  • Graphically composition is shown with darkened in arrow. Composition
Composition

4.Realization:

  • A realization is a explanation relationship between classifiers in which one classifier specifies a contract that another classifier guarantees to carry out.
  • It is denoted by Realization symbol
  • Realization is separate kind of relationship and it is across between dependency and generalization.
  • Realization is used most commonly to specify the relationships between an interface and the class or component that provides an operation.
Ex:
Realization example

How to write UML to Java code?

 UML to Java code

Example of class diagram:-

  • The class diagram is nothing but static diagram. It explains the static view of an application.
  • Class diagram is not only for visualization, describing & documenting different aspects of a system but also for constructing executable code of the software application.
  • The class diagram identifieses the attributes and operations of a class and also the constraints imposed on the system.
  • Class diagram support three types of relationships. i.e., Generalization, Association , Dependency
Ex:-
ex_clasdiagm

In the above class diagram 2 types of relationships are participated i.e., Association & Generalization. Association is their between Company & Employee. 1 Company can contain number of Employees (company side) number employees are there in one company ( Employee side) . Manager and Contractor extend Employee class.

HTML Comment Box is loading comments...