Prefer Domain-Specific Types to Primitive Types
One of the main features provided by object oriented languages are abstract data types and strong typing. Still many developers uses the primitive data types offered by the language such as String. Wrapping complex data structures as String's are simple as the object method basically can take any data, but its also an unsafe style of programming, where the developer avoids delegating appropriate quality control to the compiler.
As an example, ADA developers can write code that looks like this:
subtype Velocity_In_Nots is Float range 0..500;
subtype Velocity_In_Km is Float range 0..300;
With these types defined the statement
V3:=V1+V2; will be cached by the compiler.
By Einar Landre
This work is licensed under a Creative Commons Attribution 3
Back to 97 Things Every Programmer Should Know home page