Modeldraw
  • Welcome to Modeldraw
  • Getting Started
    • Quickstart Guide
  • FAQ
  • UML Designer
    • Common Elements
      • Comment
      • Comment Link
      • Dependency
      • Realization
      • Frame
    • Class Diagrams
      • Class
      • Association
      • Generalization
      • Composition
      • Aggregation
      • Enumeration
      • Interface
      • Association Class Link
      • Ball (Interface Realization)
      • Socket (Required Interface)
    • Sequence Diagrams
      • Lifeline
      • Activation Bar
      • Synchronous Message
      • Asynchronous Message
      • Return Message
      • Found Message
      • Interaction Frame
    • Use Case Diagrams
      • Actor
      • Use Case
      • Association
      • System Boundary
      • Generalization
      • Include Relationship
      • Extend Relationship
    • State Machine Diagrams
      • State
      • Initial State
      • Final State
      • Transition
      • Superstate
      • Concurrent Boundary
      • History Pseudostate
      • History Transition
    • Package Diagrams
      • Package
    • Deployment Diagrams
      • Node
      • Communication Path
      • Deployed Artifact
      • Internet
    • Activity Diagrams
      • Initial Node
      • Activity Final
      • Action
      • Flow
      • Decision / Merge
      • Fork / Join
      • Partitions
      • Flow Final
      • Send Signal
      • Accept Signal
      • Time Signal
    • Component Diagrams
      • Component
      • Ball (Interface Realization)
      • Socket (Required Interface)
    • Communication Diagrams
      • Object
      • Link
  • Wireframes
    • Views
    • Layouts
    • Components
Powered by GitBook
On this page
  • Understanding Composition
  • Creating a Composition Relationship
  1. UML Designer
  2. Class Diagrams

Composition

PreviousGeneralizationNextAggregation

Last updated 7 months ago

Composition is a strong form of association in UML that represents a whole-part relationship between Classes. In a composition, the lifetime of the part (contained object) is dependent on the lifetime of the whole (container object). Modeldraw allows you to easily create and manage Composition relationships to accurately model these strong dependencies in your system design.

Understanding Composition

Composition represents a strong "has-a" or "contains" relationship between classes. Key characteristics include:

  • The part (contained object) cannot exist independently of the whole (container object)

  • If the whole is destroyed, its parts are also destroyed

  • A part can belong to only one whole at a time

  • The whole is responsible for the creation and destruction of its parts

Composition is represented in UML by a solid line with a filled diamond at the end of the whole (container) class.

Examples of composition:

  • A House (whole) and its Rooms (parts)

  • A Car (whole) and its Engine (part)

  • A University (whole) and its Departments (parts)

Composition differs from Aggregation, which is a weaker form of association where the part can exist independently of the whole.

Creating a Composition Relationship

To create a Composition relationship in Modeldraw:

  1. Select the Composition tool from the toolbox

  2. Click on the part (contained) Class

  3. Move above and click the whole (container) Class

The filled diamond will automatically appear at the end of the whole class, indicating the strong ownership in the relationship.

A Composition