On-the-fly FREE Online UML Software: 30 Class Diagram Examples

What is a Class Diagram?

The UML Class diagram is a graphical notation used to construct and visualize object oriented systems. A class diagram in the Unified Modeling Language (UML) is a type of static structure diagram that describes the structure of a system by showing the system’s:

  • classes,
  • their attributes (or Properties),
  • operations (or methods),
  • and the relationships among objects.

What is a Class?

A Class is a blueprint for an object. Objects and classes go hand in hand. We can’t talk about one without talking about the other. And the entire point of Object-Oriented Design is not about objects, it’s about classes, because we use classes to create objects. So a class describes what an object will be, but it isn’t the object itself.

In fact, classes describe the type of objects, while objects are usable instances of classes. Each Object was built from the same set of blueprints and therefore contains the same components (properties and methods). The standard meaning is that an object is an instance of a class and object — Objects have states and behaviors.

Example

A dog has states — color, name, breed as well as behaviors -wagging, barking, eating. An object is an instance of a class.

UML Class Notation

A class represent a concept which encapsulates state (attributes) and behavior (operations). Each attribute has a type. Each operation has a signatureThe class name is the only mandatory information.

Class Name:

  • The name of the class appears in the first partition.

Class Attributes:

  • Attributes are shown in the second partition.
  • The attribute type is shown after the colon.
  • Attributes map onto member variables (data members) in code.

Class Operations (Methods):

  • Operations are shown in the third partition. They are services the class provides.
  • The return type of a method is shown after the colon at the end of the method signature.
  • The return type of method parameters are shown after the colon following the parameter name. Operations map onto class methods in code

Class Visibility

The +, — and # symbols before an attribute and operation name in a class denote the visibility of the attribute and operation.

  • + denotes public attributes or operations
  • – denotes private attributes or operations
  • # denotes protected attributes or operations

Parameter Directionality

Each parameter in an operation (method) may be denoted as in, out or inout which specifies its direction with respect to the caller. This directionality is shown before the parameter name.

Perspectives of Class Diagram

The choice of perspective depends on how far along you are in the development process. During the formulation of a domain model, for example, you would seldom move past the conceptual perspectiveAnalysis models will typically feature a mix of conceptual and specification perspectivesDesign model development will typically start with heavy emphasis on the specification perspective, and evolve into the implementation perspective.

A diagram can be interpreted from various perspectives:

  • Conceptual: represents the concepts in the domain
  • Specification: focus is on the interfaces of Abstract Data Type (ADTs) in the software
  • Implementation: describes how classes will implement their interfaces

The perspective affects the amount of detail to be supplied and the kinds of relationships worth presenting. As we mentioned above, the class name is the only mandatory information.

A class diagram is a central modeling technique that runs through nearly all object-oriented methods. This diagram describes the types of objects in the system and various kinds of static relationships which exist between them.

Relationships

There are three principal kinds of relationships which are important:

  1. Association — represent relationships between instances of types (a person works for a company, a company has a number of offices.
  2. Inheritance — the most obvious addition to ER diagrams for use in OO. It has an immediate correspondence to inheritance in OO design.
  3. Aggregation — Aggregation, a form of object composition in object-oriented design.

Class Diagram Example: GUI

A class diagram may also have notes attached to classes or relationships.

Free UML Software Tool

In this article, I introduce two UML Tools:

  • Visual Paradigm Community Editon (FREE) is a desktop UML tool with feature modeling capabilities. (possible update to commercial Editions)
  • Visual Paradigm Online for general uml and other diagramming drawing.

​30 Class Diagram Examples

  • Free Class Diagram examples and templates editable in an online Class Diagram software: Visual Paradigm Online.
  • Use the templates as a starting point to create your own Class Diagram.
  • (Click to Instantly Edit the Class Diagram Examples)

For your convenience, the following examples are setup in Visual Paradigm Online. You can try it straight away without configuration or installation, have Fun!

A Star-Based LAN

A Token-Ring Based LAN

Company Structure

Understanding Relationships

File Output (Use of Generalization)

Telephone (Use of Association)

GoF Design Patterns — Proxy

GoF Design Patterns — Flyweight

GoF Design Patterns — Facade

GoF Design Patterns — Decorator

GoF Design Patterns — Composite

GoF Design Patterns — Bridge

GoF Design Patterns — Adapter

GoF Design Patterns — Singleton

GoF Design Patterns — Prototype

GoF Design Patterns — Factory Method

GoF Design Patterns — Builder

GoF Design Patterns — Abstract Factory

GoF Design Patterns — Visitor

GoF Design Patterns — Template Method

GoF Design Patterns — Strategy

GoF Design Patterns — State

GoF Design Patterns — Observer

GoF Design Patterns — Memento

GoF Design Patterns — Mediator

GoF Design Patterns — Iterator

GoF Design Patterns — Interpreter

GoF Design Patterns — Command

GoF Design Patterns — Chain of Responsibility

Class Diagram — Order Process

Class Diagram — Classes and packages Constraints

Class Diagram — Class in a Package (Airline)

Ticket Selling

Self Association

Association Class and Self Association

Sales Order System

Car

Other Recommended Reading

Leave a Reply

Email của bạn sẽ không được hiển thị công khai.