Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Giving a program priority briefly



>> Refactoring is the art of changing the code to make it more
>> readable/expandable (usually with a future addition in mind, not just
>> for the sake of itself), without changing functionality. ...

> ... For example, you can see a function is called 10000 times and
> a nested loop is executed 2000 times while another part of code is
> dead. By rewriting them, we reserve the functionality of the code yet
> it becomes faster.

Changing code to make it faster (or use less of any resource), without
changing functionality, is called optimization. In contrast refactoring
is something you do for the programmer's sake, not the program's sake.

Usually you expect to lose a bit of performance when refactoring, e.g.
when you add another level of redirection. I was running the benchmark
after each change because in this case losing performance would be bad
(e.g. instantly kill interest in my patches). But I wasn't optimizing.

I think the biggest thing I got from Martin Fowler's Refactoring book
was that refactoring, adding features, and optimization should be
distinct steps (*). I tend to blur all three together if I don't think
about it.

Darren

*: Though the steps may be small, e.g. 10 minutes refactoring, 20
minutes adding a new feature and its test, 10 minutes refactoring, 20
minutes optimizing, etc.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links