• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation of arguments in Data class methods

 
Pawel Poltorak
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers

I'm thinking about validation of values passed into Data class methods. For instance what to do with negative recNo values. Instructions state that these methods should throw RecordNotFoundException if record is not found or deleted. But for me negative recNo value is an error of the programmer, and, as such, should be treated with IllegalArgumentException .

What's your opinion on this topic? Do you think adding such checks and documenting this decision in choices.txt satisfies Sun's instructions?

Regards and thanks in advance for answer,
Pawel
 
Muthaiah Ramanathan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pawel,

This is pefectly fine, according to me. And I feel, this should be the way to eliminate the unnecessary processing of the record that is not valid first of all.

Regards,

Muthaiah.
 
Pawel Poltorak
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also thought that is a better. This way programmer knows that he has error in the code, he doesn't have to debug.

Thanks for reply,
Pawel
 
Krzysiek Hycnar
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To All,

Excuse me using probably Pawel's mother language

Do Pawla

Witam najprawdopodobniej rodaka na tym zacnym forum!!!
Looknij na ten validate or not validate watek, gdzie dyskutowalismy o validacji tego co trafia do klasy Data.

Take Care
Krzysiek
[ November 02, 2005: Message edited by: Krzysiek Hycnar ]
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Krzysiek,

If you wish to post in Polish, could you please also provide an English translation for the benefit of those who do not speak Polish but who might be interested in this topic (it doesn't matter if the translation is very rough, just as long as there is some form of English translation).

As I understand it, your first sentence was just welcoming your compatriot to JavaRanch, and your second sentence was just pointing Pawel to your post on validating Dates.

Regards, Andrew
 
Krzysiek Hycnar
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,

I do not wish to write here in Polish. I'm aware that the official language on this forum is English and so far I've been doing my best to obey this rule
All I wrote to Pawel was greeting him in a funny way (looks like he's pretty new around here) and pointing to the link you mentioned.

Cheers
Krzysiek
 
Pawel Poltorak
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Czesc Krzysiek / Hi Krzysiek,

Rowniez witam rodaka!

I've read that discussion before and found it very interesting. However, I'm not going to validate data in my application. I'm going to explain in choices.txt that for now external applications are responsible for data insertion, and this is not a scope of my code. Of course, I will also write that adding this ability will be easily available by subclassing Data class.

Pozdrowienia / Regards ,
Pawel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic