Dan Cardin
2009-10-10 09:17:09
It seems like it would make sense to do something like this
rather than
using strings is bad because it allows for a lot of mistake. First, they could spell it incorrectly in the comment. Then they could spell it incorrectly when searching for it in the function. Then the user could spell it wrong. Along with it being annoying to have to put everything in 's.
The set would basically negate all the problems and if anything was incorrect, you would know it…since it would give you an error, rather than just not working, but still compiling.
type
GolfClub = (Driver, Putter, Iron);
procedure SelectGolfClub(type: GolfClub);
rather than
//you can use the values of 'Driver', 'Putter', or 'Iron'
procedure SelectGolfClub(GolfClubType: string);
which is the way SRL does it. using strings is bad because it allows for a lot of mistake. First, they could spell it incorrectly in the comment. Then they could spell it incorrectly when searching for it in the function. Then the user could spell it wrong. Along with it being annoying to have to put everything in 's.
The set would basically negate all the problems and if anything was incorrect, you would know it…since it would give you an error, rather than just not working, but still compiling.