Afternoon.
I have to write an aplication to view files created using a certain medical transfer protocol.
Question 1.
Looking at the specs, this protocol has 27 different data types. These 27 types are effectively variants on Byte, Float and char. Some of them are pretty basic like a 32 bit int (can treat as a 4 byte number), and string, but others have certain constraints attached (they might insist on only using certain characters, or a maximum number range)
Would I be better defining these as 27 structs, and writing some supporting code to ensure that each is validated as it is assigned to the struct?, or creating 27 classes, allowing each class to ensure that as part of it's constructor it can except if the data type is not correct ?
Or would I be better off again storing them internally in a language type (probably C++), and just write 27 validation functions, and 27 conversion functions to make them look correct for display ?
My last thought for doing it would be to make a template class, that will validate the type to be correct, and return a variable of the correct type, but as there are different rules for all the variations, I suspect that a template won't really save me a great deal of work.
Any ideas / comments most welcome here, as I want to make sure I start on this design only once !
Cheers,
K
I have to write an aplication to view files created using a certain medical transfer protocol.
Question 1.
Looking at the specs, this protocol has 27 different data types. These 27 types are effectively variants on Byte, Float and char. Some of them are pretty basic like a 32 bit int (can treat as a 4 byte number), and string, but others have certain constraints attached (they might insist on only using certain characters, or a maximum number range)
Would I be better defining these as 27 structs, and writing some supporting code to ensure that each is validated as it is assigned to the struct?, or creating 27 classes, allowing each class to ensure that as part of it's constructor it can except if the data type is not correct ?
Or would I be better off again storing them internally in a language type (probably C++), and just write 27 validation functions, and 27 conversion functions to make them look correct for display ?
My last thought for doing it would be to make a template class, that will validate the type to be correct, and return a variable of the correct type, but as there are different rules for all the variations, I suspect that a template won't really save me a great deal of work.
Any ideas / comments most welcome here, as I want to make sure I start on this design only once !
Cheers,
K