From: Nat Pryce Date: 2001-11-03T01:56:39+09:00 Subject: [ruby-talk:24180] Re: Modularity question From: "Hal E. Fulton" > The "Big Design" syndrome is real, but the opposite extreme is > excessive sloppiness and failure to plan ahead. > > I think of it as "prefactoring" -- as far as I know, I made up that > word. No charge for that. > > I'm not talking about a gigantic productivity improvement, of course... > I'm talking in the realm of "an hour of prefactoring is worth two hours of > refactoring." My experience is that "prefactoring" is advantageous only when refactoring is not being done correctly. After you have added functionality, you should refactor your code so that it expresses that functionality in cleanest way possible -- following rules such as Once and Only Once, using your system of names, and so on. One should not refactor and implement at the same time, and one should not implement without refactoring if it leaves the code in a sloppy state. In practice this refactoring does not happen after you have added *all* your new functionality, but after each small unit of functionality is added. One works in small iterations of (1) writing a unit test to express the next unit of functionality to be written, (2) refactoring the code to allow you to write that functionality (3) implementing new functionality until the unit test passes, and finally (4) refactoring so that the new functionality is clear and readable. This way the code does not become sloppy, and you don't have to worry about planning ahead to cope with things that you cannot actually anticipate. Cheers, Nat.