Re: DataValidator class?
- From: Andrea Francia <andrea.francia@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 17 May 2008 11:40:47 GMT
thufir wrote:
I have a few related classes which throw a DataException from the constructor if the data passed is invalid. I can't exactly say that the data validation is exactly the same for these classes, but they're similar. Basically, count the number of String[] elements, try to parse Integer or Float values and so forth; there's some overlap.Where come from these String of the String[] array?
You are putting the parsing of the Strings in the object constructor.
What's the standard approach? Multiple anonymous inner classes? A static utility class? Verify the data before sending it to the constructor?
For better reusability I suggest you to move this responsibility to another class called Parser that read the Strings and returns the parameters to be used for calling the the object constructor. If the parsing fails it throws a ParseException.
Or, create a DataValidator class which the constructor instatiates?
thanks,
Thufir
--
Andrea Francia
http://code.google.com/p/remoted-list/ - Lazy loading lists through RMI.
.
- References:
- DataValidator class?
- From: thufir
- DataValidator class?
- Prev by Date: Re: Help with a loop
- Next by Date: Re: Is there a "Push" technology for (entry) fields? Force fileds to be updated from server possible?
- Previous by thread: DataValidator class?
- Next by thread: how to set a state
- Index(es):
Relevant Pages
|
|