http://www.perlmonks.org?node_id=982490


in reply to Re^3: Universal test flag
in thread Universal test flag

the hard truth in the commercial world

Oh, you apparently think that I'm living off charity and only write abstract examples ;)

refactoring always falls in second place, after you get the (ever changing) functionality pinned down

refactoring is not something you do after implementing functionality, it is something you do to implement functionality in a most efficient way (and so save time and money)

Replies are listed 'Best First'.
Re^5: Universal test flag
by ait (Hermit) on Jul 19, 2012 at 12:07 UTC
    Oh, you apparently think that I'm living off charity and only write abstract examples ;)

    No sir, I don't make those assumptions ;-)

    What I'm saying is that it's very different, for example, to code a well thought-out CPAN library, than working on a large system with a team of coders at different levels, with time and money constraints.

    I think that your comments refer more to design than to the process of coding. Refactoring by very definition is a continuos and disciplined process after the fact, so your assumption above is actually wrong and must not be confused with good design. Good design is paramount, and that is not in discussion.

    Furthermore, to actually be able to refactor you must first have a solid set of tests so when you actually refactor, you can guarantee the same functionality that should have been pinned down beforehand.

      to actually be able to refactor you must first have a solid set of tests

      And the exact problem with what you are trying to do is that it isn't solid. Suppose later you extract SMS sending code into a separate module, will your tests help you to find if you broke anything? No, because the code that may be broken by the change is being skipped in the test mode.

      So what I would do, is to write solid test, and refactor code to pass it.

        I think we are talking about two different things here. I understand what you are saying but this is not the case that the SMS code is inside the function and later factored out (in fact the SMS part was a made-up example to illustrate). I'm talking about the the case where the sub you are testing calls something else and you want to skip that, the same way you may skip tests in your test harness.