Re: What name for a printer status supplies module?

2004-12-18 Thread Ken Williams
On Dec 17, 2004, at 4:02 PM, David Landgren wrote:
The biggest problem I see is how to avoid having to sketch out 
everything up front. I think it's only after I get 3 or 4 
Printer::Status::x::y modules under my belt that I'll *begin* to get a 
feel for where the divisions lie and what methods can be hoisted up 
the namespace to Printer::Status::X or Printer::Status.

For instance, the older 4500 model had three cartridges: drum, 
transfer and fuser. The new one only has two, they did away with the 
drum. Not all models have the same consumables; two models may have 
none in common. I'm not sure how to represent this elegantly. What I 
do know is that I don't want to build up a towering hierarchy of 
classes for something which is, at the end of day, really pretty 
trivial.

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.:

 $stuff = $printer-consumables();
 # $stuff is now:
 { drum = {
 whatever you know about the drum
  },
  transfer = {
 whatever you know about the transfer
  },
  fuser = {
 whatever you know about the fuser
  },
 }
I think Perl's built-in ways of interrogating hashes should be 
sufficient for what people will want to do with the information.

 -Ken


Re: What name for a printer status supplies module?

2004-12-18 Thread Terrence Brannon
David Landgren [EMAIL PROTECTED] writes:

 The fact that it uses http is incidental. If HP bothered to supply a
 half-decent MIB, SNMP would be a good alternative.

What does MIB stand for?



Re: What name for a printer status supplies module?

2004-12-18 Thread Christopher Hicks
On Sat, 18 Dec 2004, Terrence Brannon wrote:
David Landgren [EMAIL PROTECTED] writes:
The fact that it uses http is incidental. If HP bothered to supply a
half-decent MIB, SNMP would be a good alternative.
What does MIB stand for?
Men In Black.  ;)
Oh, you mean the geek version...  MIB stands for Management Information 
Base and encapsualtes an API within an SNMP context for a given type of 
device.  Various RFC's have described this through various versions of 
SNMP: http://www.drunkandretired.com/snmp/ has some good links.

--
/chris
There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order.
-Ed Howdershelt (Author)


Re: What name for a printer status supplies module?

2004-12-18 Thread Ovid
--- 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.

Cheers,
Ovid

=
Silence is Evil
http://users.easystreet.com/ovid/philosophy/decency.html
Ovid   http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/


Re: What name for a printer status supplies module?

2004-12-18 Thread Ken Williams
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


Re: What name for a printer status supplies module?

2004-12-18 Thread Ovid
--- Ken Williams [EMAIL PROTECTED] wrote:
 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. 

  if (exists $status-{toner}) {...}

That is not conceptually different from:

  if ($status-exists('toner')) {...}

Which is a very small step from $status-can or UNIVERSAL::can($status,
...).

It sounds to me like the only difference of opinion is in the syntax,
not the merits of sanity checking.  If so, it just falls back to the
original author to decide.

Cheers,
Ovid

=
Silence is Evil
http://users.easystreet.com/ovid/philosophy/decency.html
Ovid   http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/


Re: What name for a printer status supplies module?

2004-12-18 Thread David Landgren
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


What name for a printer status supplies module?

2004-12-17 Thread David Landgren
List,
I have some code that queries an HP LaserJet 4600 printer to retrieve a 
web page, that I then scrape to pick out the values of the various 
consumables it has (CMYK cartridges and other kits).

The fact that it uses http is incidental. If HP bothered to supply a 
half-decent MIB, SNMP would be a good alternative.

Anyway, I now have to deal with other HP models, and Ricoh 
printer/copiers as well.

And I haven't a clue what namespace to use. Your advice is much appreciated.
Thanks,
David


Re: What name for a printer status supplies module?

2004-12-17 Thread Lincoln A. Baxter
On Fri, 2004-12-17 at 21:21 +0100, David Landgren wrote:
 List,
 
 I have some code that queries an HP LaserJet 4600 printer to retrieve a 
 web page, that I then scrape to pick out the values of the various 
 consumables it has (CMYK cartridges and other kits).
 
 The fact that it uses http is incidental. If HP bothered to supply a 
 half-decent MIB, SNMP would be a good alternative.
 
 Anyway, I now have to deal with other HP models, and Ricoh 
 printer/copiers as well.
 
 And I haven't a clue what namespace to use. Your advice is much appreciated.

Printer:: comes to mind.  How about:

Printer::Status::Brand::Model

Brand could provide the a common interface around (and wrap) Model.

And Status could provide the generic interface for printer status.

Just some thoughts...

Lincoln