Consider building another layer of abstraction into your current code.

As I understand your question, you don't want to get stuck searching-and-replacing function names in the code that uses these two libraries. By and large, that means both your brain and your survival instinct are in good working order. ;-)

A set of wrapper functions will let you modify your client code once, then switch between the two different libraries with ease. If your client code presently looks like this:

{...} $some_value = old_parser_function_X (@args); {...}

Swap in a generic function name, and then create a new function which calls the original one:

-- client code -- {...} $some_value = generic_function_X (@args); {...} -- wrapper library -- sub generic_function_X { return (old_parser_function_X (@_)); }

The payoff is that you can now write another wrapper that calls functions from your new parser library:

-- new wrapper -- sub generic_function_X { {assemble a result by calling: new_parser_function_A (@some_args) new_parser_function_D (@some_other_args) new_parser_function_N (@still_more_args) } return ($result); }

and it will work as a drop-in replacement for the old wrapper, even though the two parser libraries have completely different APIs.

Writing a test suite that compares the two wrapper libraries then becomes a one-banana problem.


In reply to Re: Clean code transition - how? by mstone
in thread Clean code transition - how? by shemp

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.