4 ms·
Why would you have a wrapper around every primitive/standard library type?
by dieortin 2y ago
Why would you have a wrapper around every primitive/standard library type?
- kccqzy 2y agoType safety. Compare `int albumId, songId;` versus `AlbumId albumId; SongId songId;`. The former two variables can be assigned to each other causing potential bug and confusion. The latter two will not. Once you have a basic wrapper for integers, further wrappers are just a one-liner so why not. And also in practice making the type more meaningful leads you to shorter variable names because the information is already expressed in types.