Very nearly correct. An interface is a defined way for one piece of code to interact with another. Your code is already using interfaces informally - every module you use is accessed through an interface: the stuff it makes public.

The trick here is to define the interfaces that you need and to write tests against those interfaces. Defining interfaces allows you to partition the code off so that things can be worked on independently on either side of the partition without. And yes, the benefit is exactly as you describe.

The initial hard work is identifying where formal interfaces are required and implementing them. The implementation should be fairly light weight and should be a simple matter of writing a new module for each interface that receives calls from the old "client" code and passes those calls through to the old "server" code. Here "client" is simply the calling code and "server" is the called code. The intent is to emphasise the point that there are two sides to the interface. The interface itself is just a line drawn in the sand. The temporary module I suggest is just a shim that allows implementation of the interface on your existing code so that tests can be written against it.

Note that this fits very nicely with the "Strangler Application" technique mentioned in one of the other replies you received.


DWIM is Perl's answer to Gödel

In reply to Re^5: OT: Rewrite or Refactor? by GrandFather
in thread OT: Rewrite or Refactor? by badaiaqrandista

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.