UML Basics

UML (Unified Modeling Language) diagrams to visualize relationships among classes and objects.
A UML class diagram consists of one or more classes, each with sections for the class name, attributes, and methods. Depending on the goal of the diagram, the attribute and/or method sections can be left out of any class. In a UML diagram, each class is represented as a rectangle, possibly containing three sections to show the class name, its attributes (data), and its operations (methods).

UMLBasics

Keep in mind that UML notation is not intended to describe a program after it is written.

It’s primarily a language-independent mechanism for visualizing and capturing the design of a program before it is written.

Take a look at these 3 scenarios:

association

When classes are “aware” of each other, objects of those classes may use each other this often is referred to as a “use relationship”.

Die-n-driver-UML

code-rolling-dice

code-diefacevalue

In the next example, the line connecting FlipRace and Coin indicates a basic association. The number 2 represents the association between FlipRace and 2 Coin objects.

Coin-n-driver-UML

code-flipping-race

aggregation

Some objects are made up of other objects. A car, for instance, is made up of its engine, its chassis, its wheels, and several other parts. Each of these other parts could be considered separate objects. Therefore we can say that a car is an aggregation—it is composed, at least in part, of other objects. Aggregation is sometimes described as a “has-a relationship”. For instance, a car has a chassis.
In UML, aggregation is represented by a connection between two classes, with an open diamond at the end near the class that is the aggregate. Strings are so fundamental to programming that they are usually represented the same way a primitive attribute is represented.

Student-Agregate-UML

code-stu-body

code-address

code-stu


Screen Shot 2014-10-14 at 1.49.17 PM

Screen Shot 2015-10-27 at 9.02.22 PM

Visual Paradigm

Screen Shot 2014-10-20 at 1.50.41 PM

Simple Class w main UML

Two Simple Classes