Microtypes

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 behviour 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.


Browse Space

- Pages
- Blog
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced
- Activity

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

 

Other Features

Add Content

- Add Comment