Skip to content

UML Introduction

A simple introduction to UML (Unified Modeling Language)

Unified Modeling Language

UML is an industry standard way of modeling objects. It can be used to better understand objects and object-oriented programming, and to make it easier to conceptualize programming objects - the UML diagrams act like a template that can be used to write code from.

Pet
EyeColor: String
Age: Float
Weight: Float
Location: String
eat(foodType)
sleep(timeLength)

Unified Modeling Language (UML) is a standardized general-purpose modeling language in the field of object-oriented software engineering. The Unified Modeling Language includes a set of graphic notation techniques to create visual models of object-oriented software-intensive systems. (source)

A very simple version of UML can be used to model a class.  A class diagram describes a template for creating multiple versions of something. Information about what is being created is stored as attributes (also called fields or properties). What the thing can do is described as operations (also called methods, behaviors, or functions).

Once you have a class diagram, you can make object diagrams that represent instances of the class. You can make multiple instances, and each can have unique information.

Generalization and Inheritance

Generalization is the process of extracting shared characteristics from two or more classes, and moving them into a parent class (called a 'base class'). Child classes (called 'derived classes') will inherit the shared characteristics.

UML Inheritance

An example would be three pets: a bird, a cat, and a fish. All three pets might have the attributes 'name' and 'age', and all three might 'eat' and 'sleep'. These common characteristics can be placed in a base class called Pet. The things that are unique about each of the pets would remain in the derived classes.

To see an example of a simple application's code expressed as a UML diagram see C# Hello World.