0.4.8 Choosing a Data Type for Information

Video: Types Revisited (8:45)
Start With What the Value Means

Choosing a data type begins with the information, not with the code.

A useful question is:

Consider several pieces of soccer information:

Information Example value
player name "Jordan"
jersey number 7
goals scored 3
height in meters 1.82
available for match true

The meaning of each value suggests the kind of representation the program should use.

Use Text for Words, Labels, and Identifiers That Are Not Calculated

A player's name should be represented as text:

Activity diagram showing playerName text, then jerseyNumber whole number, then goals whole number, then heightMeters fractional number, then isAvailable Boolean.
PlayerNameText.
  • New
  • Changed
  • Removed

This does not tell you how the application will be coded yet.

It tells you what kinds of information the model needs to represent.

That type thinking becomes visible in UML class diagrams.