Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Comments and suggestions on new module

by tonyc (Pilgrim)
on Sep 19, 2007 at 01:04 UTC ( #639776=note: print w/replies, xml ) Need Help??


in reply to Comments and suggestions on new module

As LTjake suggests, you might want to create a subclass for each of the imaging libraries you support.

For example, you have a line() method, instead of defining that in Image::Mate with a huge conditional for each implementation, you simply define it in each of the derived classes. Then have Image::Mate::new() return an object of that type.

Imager does something similar for its font support - Imager::Font itself doesn't know how to draw text, it lets Imager::Font::(Truetype|Win32|FreeType2|Type1) specialize _draw() which does all the heavy lifting.

This is pretty basic OO.

Another issue I see is that you appear to load every one of the imaging libraries even though the user would only want to use one of them, and you then call import() in package main for that module.

The use of the c option to new() seems a bit inconsitent too - for GD this is used to decide between a paletted image and a true color image, for Imager it's used to decide between an 8-bits/sample image (24-bit color) and 16-bits/sample (48-bit color), but I suspect this is a case of trying to make sense of the different options the modules support.

  • Comment on Re: Comments and suggestions on new module

Replies are listed 'Best First'.
Re^2: Comments and suggestions on new module
by cosmicperl (Chaplain) on Sep 20, 2007 at 14:57 UTC
    Your right it is my trying to make sense of the different options they support. Not all the doc's are straight forward, certainly not for ImageMagick.

    I'll brush up some more on my OO, be be honest I haven't made any OO code with Perl before so it's all pretty new to me.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://639776]
help
Chatterbox?
[GotToBTru]: I would think temporary variables would help in making the real life meaning of your structure clear
[choroba]: the problems start when you want to "skip a level", i.e. the arrays for all the keys
[LanX]: what are temps?
[moritz]: oh, the question was about creation, not indexing
[thepkd]: temporary variables
[moritz]: [ { a => [ { b => 1 } ] } ]
[choroba]: dereference ne creation
[choroba]: at least in my lingo
[moritz]: .oO( oh temps, oh moritz )
[GotToBTru]: you are correct, choroba, but of course there is no point in doing one without the other

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2016-12-06 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (104 votes). Check out past polls.