Friday, July 1, 2022

C++ API Design Best Practices - UML Class Diagrams


Box that is segmented into three parts

  • The upper section contains the class name.
  • The middle section lists the attributes of the class.
  • The lower section enumerates the methods of the class.

Symbol to indicate the access level, or visibility, for that attribute or method.

  • + indicates a public class member
  • - indicates a private class member
  • # indicates a protected class member

Relationships between classes are illustrated with various styles of connecting lines and arrowheads.

  • Association: A simple dependency between two classes where neither owns the other, shown as a solid line.
  • Association can be directional, indicated with an open arrowhead such as “>”.
  • Aggregation: A “has-a,” or whole/part, a relationship where neither class owns the other, shown as a line with a hollow diamond.
  • Composition: A “has-a” relationship where the lifetime of the part is managed by the whole. This is represented as a line with a filled diamond.
  • Generalization: A subclass relationship between classes, shown as a line with a hollow triangle arrowhead.

Specify Multiplicity whether the relationship is one to one, one to many, or many to many.

  • 0..1 = Zero or one instances
  • 1  = Exactly one instance
  • 0..* = Zero or more instances
  • 1..* = One or more instances

No comments:

Post a Comment

LeetCode C++ Cheat Sheet June

🎯 Core Patterns & Representative Questions 1. Arrays & Hashing Two Sum – hash map → O(n) Contains Duplicate , Product of A...