Skip to end of metadata
Go to start of metadata

Passing Strings and doubles around in an application can significantly increase the likelihood of inadvertantly passing incorrect parameters to methods. By strongly typing all string and number parameter types, this can be simply avoided. Its then also possible to add behaviour to these types, meaning that "utility" classes are removed, keeping behaviour close to the objects that need it.

Numeric Microtype

Here is an example base class for a numeric microtype. It exposes basic numeric operations, and also allows for derived classes to specify the maximum amount of accuracy that the type will allow.

A Concrete Type

Here is an example of a concrete numeric type.

A base string class

A Concrete Class

Note that we use a static method, rather than a constructor to create the object, it has exactly the same effect, but is just that little bit more readable.

It makes the code read much more like english when you have

rather than

Labels: