Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: OT: Rewrite or Refactor?

by badaiaqrandista (Pilgrim)
on Aug 27, 2006 at 21:20 UTC ( #569899=note: print w/replies, xml ) Need Help??


in reply to Re^3: OT: Rewrite or Refactor?
in thread OT: Rewrite or Refactor?

I think I'm starting to understand what you are saying. The key term that is still sound vague for me is interface. My understanding of it is: interface is a small application that initially uses the code that I want to modify, which then changed to use the new code when the new code is ready. Hmmm. So I need to tests the behaviour of the interface instead of the code I want to change. Is that correct?

This is Brilliant!!! Pure Genius!!! This way I can be 99% sure that the new code behaves like the old code and that confirmation comes from the exact same test while I can significantly change the code. Thank you GrandFather. I wouldn't think of it myself. ++ for you. I guess I have to read up a lot more about refactoring technique.

Thank you

-cheepy-

Replies are listed 'Best First'.
Re^5: OT: Rewrite or Refactor?
by GrandFather (Sage) on Aug 28, 2006 at 00:01 UTC

    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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://569899]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2020-10-19 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (205 votes). Check out past polls.

    Notices?