Well... I can't say I'm enthusiastic about your approach here. Objects are slow enough without turning every method into a wrapper around another sub call; and I don't see how a proceedural module is any eaisier to write tests for than an object-oriented one (though, to make testing a little eaiser, I'm inclined to design my object classes so you can get a bare-bones object with a simple "new" without arguments).

A typical test for me is something like:

{ my $test_name = "rect_probe"; my $bf = Image::BoxFinder->new(); my $spot = $bf->rect_probe; is_deeply( $spot, [ 0, 0 ], "Testing $test_name: found rectangle"); }
The extra line to create the object isn't a lot of overhead; and myself I just think of the method call ($bf->) as just a short alias for Image::BoxFinder::.

On the subject of mixing and matching methods and proceedures in one module: this makes some people queasy, and I have mild reservations about it myself, though they're only mild.

On the subject of modules with both an object and a proceedural interface, myself I think they're over-kill. Remember: if you put in two totally different interfaces, you're going to have to document both of them.


In reply to Re: Is it ok to mix functional and oo programming in one package? by doom
in thread Is it ok to mix functional and oo programming in one package? by leocharre

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.