This is the 65th Step towards gaining the Programming Enlightenment series. If you didn’t learn the 64th Step, read it.
What is Primitives?
It is a basic type of data type provided by a programming language. We can create more complicated using these basic types. Examples, int, float, boolean, etc.
What is Domain-Specific Types?
Also known as Abstract Data Types. These are the more complicated data types that are constructed using the primitive data type. The class represents the Domain-Specific types in modern languages. Example; VelocityInKnots, DistanceInNauticalMiles, UserAge, UserSex, etc.
Why use Domain-Specific Type?
- The code becomes more readable as it expresses concepts of a domain, not just float or string.
- The code becomes more testable as the code encapsulates behavior that is easily testable.
- The code facilitates reuse across applications and systems.
- The compiler gives an error for statically typed languages whereas, unit tests will help for the dynamically typed languages.
TL;DR Start exploring domain-specific types for the purpose of developing quality software.
Go to 64th Step
Go to 66th Step
References:
- 97 things Every Programmer Should Know ~ Git Book
- 97 Things Every Programmer Should Know ~ Paperback
- Primitive Data Type ~ Wiki
- Abstract Data Type ~ Wiki