|
-
Aug 19th, 2009, 01:17 AM
#9
Re: [RESOLVED] Problems having a function return two values
 Originally Posted by tassa
OK, I fixed the first point and the second point. I don't understand why I should be using two statements if I can do it in one.
There's no rule that says one method is better than two. Clarity is important and in this case two methods is clearer than one. As far as the caller is concerned it makes no difference. As it stands you've got an optional parameter so the user can call the method with one argument or two. If they pass one then no salt is generated and if they pass two it is. The same goes for my code. The caller would use the same method name with one argument or two.
Your code simply won't pass back the generated salt as is. In order to do so you'd have to add a third parameter that would pass the salt back ByRef, but that would make no sense if the user specified False for generating salt so the code becomes nonsensical. Two methods is clearer and cleaner so you should use two methods, or three if appropriate.
Never let writing fewer methods be something you strive for. You write as many methods as are appropriate for the circumstances.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|