http://www.perlmonks.org?node_id=259939


in reply to Re: Short Refactoring Tip: let the object do it for you
in thread Short Refactoring Tip: let the object do it for you

That's a very interesting observation. Given what you've written, how would you handle this?

[% IF item.can_receive %] <input type="text" name="received" value="[% item.received %]" cla +ss="input2"/> [% ELSE; item.received; END %]

In the above case, I am querying whether or not an item can accept a value for given attribute (those are Template Toolkit directives). If so, an input box is presented to the end user, with the current value filled in. If not, they only see the value. As this data can be represented in many other ways (and not just on HTML forms), it doesn't seem to make sense to have the object present HTML code to the end user. I like the idea of moving the conditional logic into the object, but I don't see a clean way of doing that.

Cheers,
Ovid

New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)