in reply to Re^14: Assignable Subroutines
in thread Assignable Subroutines
That statement is sidestepping the debate. Why are you setting the salary field to "$50000"? What is the thought process behind it? Why aren't you letting the object do more of the thinking?
Let's explore this situation a little more. I can see three reasons why you would want to set the salary.
This should be done as part of the initial creation of the Employee object. There should be a method that accepts a large number of parameters, presumably named and not positional, and will validate those parameters before accepting them.
The object should be handling all the math, not you. You should be calling the giveRaise() method. That method should be able to accept a number or a percentage. That method will do all the bit-fiddling.
The object should be handling this. There should be a givePromotion() method that, as one of its optional parameters, accepts a new salary value. That method will do all the bit-fiddling.
Now, the object enforces the business rules of the HR department. You can't just walk into someone's cube and say "Hey, I decided to set your salary to $50000. Have a nice day!" and expect the HR department to be ok with it. (Depending on the prior salary, the employee might not be ok with it, either!)
I am starting to become convinced that everytime someone says "I need a mutator here!", they're really saying "I haven't fully thought out my problem, but I know I can bruteforce it with a mutator!" I'm not saying that brute force is necessarily a "Bad Plan"™. I am saying that it's not good theoretical practice.
Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^16: Assignable Subroutines
by fergal (Chaplain) on Jan 27, 2005 at 20:53 UTC |