The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by HS Thomas:
I don't just mean compiled and tested code.
Originally posted by Junilu Lacar:
While you're refactoring, you notice that some part of the code could be refactored to make maintenance easier. Do you refactor that too? I would tend not to since I don't know for sure if it will be needed. I might, as a courtesy, leave a quick comment [...]
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
The Code is the Programmer
If good Coding Styles, good Design practises (this one is the difficult one ) are communicated early enough, there would be less need to refactor.
Refactoring , without really knowing how , could do more damage than good.
Seems to me , refactoring belongs to the Design and Test planning stage rather than after the code has been written. Or, rather it should be emphasised more at these stages. Oh , I don't know, perhaps there should be a split - Design Refactorings and Coding refactoring.
I can't imagine a good designer is required to know what a typesafe enum is.
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Originally posted by Junilu Lacar:
Well, for example, I might have some static finals that might look like candidates for refactoring to the typesafe enum pattern. I don't usually refactor them right away. If I can live with that "sin", I'll usually wait until later when I know it would definitely benefit the design.
IIRC, one of the books in the XP series has a discussion related to this question and "museum quality" code. I'll have to check what was said but I think the gist of it was that it is not in the interest of speed to spend too much time bringing your code up to "museum quality."
Isn't this an example of how one practice balances another: YAGNI vs. merciless refactoring?
I'm reviewing "Secure Coding" right now and they use a phrase I think applies to the approach I take:
How secure should your application be? Answer: "Just secure enough."
In the case of refactoring, I stop when the code is "just smell-free enough."
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by HS Thomas:
Seems to me, refactoring belongs to the Design and Test planning stage rather than after the code has been written. Or, rather it should be emphasised more at these stages.[ July 23, 2003: Message edited by: HS Thomas ]
Originally posted by HS Thomas:
These responses indicate that refactoring is the "cure" for badly evolved systems.
This "badness" may be due to :
1. Bad Coding Style
2. Bad Design -assumptions are made that don't suit or not communicated well ; hence classes not used as they should and instead overridden heavily
... and other factors.
I just wondered whether it better to take the stance that Prevention is better than cure .
If good Coding Styles, good Design practises (this one is the difficult one ) are communicated early enough, there would be less need to refactor.
Refactoring, without really knowing how , could do more damage than good.
Seems to me, refactoring belongs to the Design and Test planning stage rather than after the code has been written.
I can't imagine a good designer is required to know what a typesafe enum is.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
If it stinks , change it ...
-- Grandma Beck, discussing child-rearing philosophy
Originally posted by Ilja Preuss:
"museum quality" ... I would be interested in knowing exactly which book that is and what it said...
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
.Refactoring , without really knowing how , could do more damage than good.