12.4. Non-primitive Data Type Classes

The type of an attribute may be expressed as a non-primitive class in its own right in a domain model. For example, in the POS system there is an item identifier. It is typically viewed as just a number. So should it be represented as a non-primitive class? Apply this guideline:

Represent what may initially be considered a primitive data type (such as a number or string) as a non-primitive class if:

  • It is composed of separate sections.

    • phone number, name of person

  • There are operations usually associated with it, such as parsing or validation.

    • social security number

  • It has other attributes.

    • promotional price could have a start (effective) date and end date

  • It is a quantity with a unit.

    • payment amount has a unit ...

Get Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.