It's not a secret anymore!
The moose likes Cattle Drive and the fly likes Question on 4a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Question on 4a" Watch "Question on 4a" New topic

Question on 4a

Deza Linikeli

Joined: May 07, 2003
Posts: 6

It's it odd to enjoy getting nitpicked? I really am enjoying this assignment but had a question concerning the method, other than the main method.

After reading the make your own method in preparation for 4b I realized that the more specific methods were private. So I changed mine from public to private. Now that it�s private how concerned with validating input should I be? Is it correct to check if the parameter is not null? In the example no validation is done, so does that mean since it is private the members of your class that use it are responsible for the validation?

Also, is it common set the value for a number between 0-19 in the main method, or do most move it out to the other method?

Thanks for such a great place to learn, and for patience and quick nitpickers!
dav mccartney
Ranch Hand

Joined: Feb 22, 2004
Posts: 45
I'll chime in here really quick, but I'm sure others will have more to say

You probably want to validate the data before passing it on to the private method. If you look at some of your instructor solutions, you'll see how they've validated early on, well before any other methods are called.

So, if you validate on the outside, you won't have to on the inside (at least in this case)

Also... you'll probably have to have more than 1 method of your own

Good luck to you!
[ August 24, 2004: Message edited by: dav mccartney ]
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
Good point about validating before passing the data, Dav.

In Assignment 4a, some people don't need more than just the main method. However, in Assignment 4b, a student definitely needs more than one method.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Asanka Nanayakkara

Joined: Aug 13, 2002
Posts: 10
The first place to validate your data is whenever you get an input or asign your data. Its like getting security clearance before you entering a top secret building. Security check at the entrance.
I agree. Here's the link:
subject: Question on 4a
It's not a secret anymore!