Class Diagram Example: GoF Design Patterns - Composite

Description:

Composite design pattern is one of the Gang of Four (GOF) design patterns. Composite design pattern facilitates the creation of object hierarchies where each object can be treated independently or as a set of nested objects through the same interface.

Draw your class diagram by using this Composite design pattern template as a starting point. Simply Click Use this Template to edit, or click Create Blank to draw from scratch.

What is Class Diagram?

Class diagrams still represent by far the most important and widely used modeling technique of UML. A class diagram is a static model of a system which shows the structure of the software in terms of the constituent classes and how each class is related to other classes. A class diagram gives a static view of the system. As opposed to a dynamic view, which describes what the software does when it runs, a class diagram provides a static view, which describes the classes that make up the software. Class Diagrams can also be used to generate source code for system implementation.

How to draw Class Diagram?

The following guideline should be consider while developing a class diagram -

  • Use meaningful name for a class to describe the aspect of the system.
  • If you are involved in a large organization, it is better to refer to the glossary for existing class for reuse and to avoid it end up to be many variants for similar classes that serve the same purpose in the repository
  • Responsibility (attributes and methods) of each class should be clearly identified only in the detailed design phase and it is not necessary to do it in upfront.
  • Refine and elaborate your class model in just-in-time manner and do not rush every detail in the upfront.
  • You don't have to include all classes in one single class diagram, for example, include only the group of classes that participate in a use case scenarios and no others.
  • Reuse classes by use master view and auxiliary view among different class diagrams.
  • You can also avoid cross relationship link between classes by using auxiliary view of the same class to be appeared within the same class diagram.
  • Package related classes together to enforce software architecture and best practice such as MVC framework.

When to use Class Diagram?

As a sketch:

  • Perform visual modeling rather than lengthy textual description
  • Casually use for illustrate initially ideas develop without the need of upfront requirement documentation
  • Instant revise from code to class diagram to pinpoint a specific problem
  • Used it to visual model to get rough selective ideas just in time whenever needed

As a blueprint:

  • a complete design to be implemented
  • typically done with a proper UML modeling tools

As code engineering:

  • Perform model to code forward engineering
  • Perform code to model reverse engineering
  • Keep code and model in sync by performing round-trip engineering

As data engineering:

  • Design data modeling based on detailed class diagram
  • Reverse class or object wrapper base on database
  • Use database framework such as Hibernate ORM Framework

As Web API generation

  • Generate web API based on Class Diagram such as SWAGGER

Keen to try VP Online?

No limitations, no obligations, no cancellation fees.


Start a Free Trial