Alex Stojan
Posts: 95
Nickname: alexstojan
Registered: Jun, 2005
|
|
Re: SANS Compiles Top 25 Most Dangerous Programming Errors
|
Posted: Jan 20, 2009 11:19 AM
|
|
> > > So if I'm writing a library and I don't know what the > > > range is for your needs, what do I put in there > instead > > of > > > "r(10,20)"? > > > > The user of your library will specify what range they > > need, not you, the library designer; you would just > create > > the range class with the necessary member functions. > > So I need to expose implementation details so that the > user can specify the range of the variables in my > classes? >
Your class would validate the range on assignments, you could just expose a few useful functions or maybe some explicit conversion operators (i.e. from range to int, if the user specified the range to be of integer type), etc.
> In any event, if it's up to the user to specify the > limits, what makes this approach better than any of the > other ways data can be validated?
This was just my response to someone's previous post about having language construct to specify a value range, and they gave an example from Pascal and Ada. So, i'm saying that it's better to have the language provide facilities to create such user-defined objects instead of having built-in constructs for it.
|
|