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.  If one
doesn't want the overhead of creating a class just for the returned
data, one call always use the excellent Hash::AsObject
(http://search.cpan.org/~nkuitse/Hash-AsObject-0.05/) module.

Oooh, I didn't know about that module. That's very nice actually, because a kit has quite a number of attributes, not just "percent remaining". In fact, an HP 4600 kit doesn't even have that.


What it does have is "number of pages printed so far", "number of estimated pages remaining, based on a historical page coverage of x%", "serial number" and a few other odds and ends. Hash-AsObject will remove a lot of the grunt work, thanks for the tip.

David



Reply via email to