in reply to Clean code transition - how?
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.
|
|---|