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:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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: