On Dec 18, 2004, at 12:26 PM, Ovid wrote:

--- Ken Williams <[EMAIL PROTECTED]> wrote:
If I were you I'd not use classes to model that part of it.  Just
have
a Printer::Status::HP4500 (or HP::HP4500 or whatever) object with a
components() or consumables() method that returns a hash mapping name
to properties.  E.g.:

"If you say you're going to take Vienna, take Vienna."

Napoleon

In this case, if an OO interface is provided, it should be used.  A
hash mapping makes it very easy to mitsype (sic) the key names.  It's
more difficult to mistype method names and have it still work.

Yeah, but if the method interfaces are going to be different for different printers (because they have different consumables), then you're going to have to use if($status->can('toner')) etc. instead of if(exists $status->{toner}) etc. I find the former weird in this case. And how would you iterate over all the consumables of a printer? It's going to take some extra "design" to cover the use cases.


 -Ken



Reply via email to