But as I already said in the thread with dragonchild, he's missed a few reasons for changing the salary and he's missed a couple of methods of calculating the new salary. So basically what you'll end up with is a combinatorial explosion of salary adjusting methods. n methods where n = (# reasons) * (# ways of calculating new salary).

So lets refactor slightly and have a business level interface (where changes to salary require a reason). You may have several specific methods and probably one that says "just set it to this much and here's a piece of text for the audit log about why I did it". All of these will need to call the actuall Salary method on a lower level object and also put something in the log. It should not be the responsibilty of the Employee object to handle logging.

Moving away from Salary and business rules, it's quite possible that you just want to change a field's value without supplying any other information. As someone else pointed out, the object may then need to signal observers to update the gui or whatever but the thing requesting the change just wants to treat it like a struct.


In reply to Re^18: Assignable Subroutines by fergal
in thread Assignable Subroutines by dragonchild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.