Don’t use primitives to represent domain ideas.

Use Value Objects instead.

An account number is not an integer. Neither is phone or SSN.

Interest rates are not floats.

An amount of money is not a float.  And using an integer to represent pennies is not good either.

Instead, use the Value Object pattern. Creating small classes that represent these domain ideas gives you much more control over their behavior.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: