Posted By: phreaks | Aug 24th @ 9:35 PM
page 1 of 1
Comments: 3 | Views: 415
I'm looking for some refactoring tips.

 

Can anyone give me some?  I consistantly spend way too much time refactoring, how do I know when some code is good enough?

 

Dr Herbie
Dr Herbie
Horses for courses

Well, that's not an question that can be answered -- it's like asking an artist when does he know when to stop adding paint to the picture, or asking a gardener when do they stop adding and moving plants.

 

I tend to stop when each method can be viewed within one screen (no scrolling), when there is little or no crass repitition, and when I feel that each class is a single responsability.

I regard 'crass repitition' as code that looks like it could have been cut-and-paste. There's always SOME repitition (like I always check parameters at the start of a method, but I'm not going to create a 'generic parameter checking method' to reduce the repitition).

 

Of course that doesn't stop me noticing stuff later on that I think I should refactor, at which point I'll decide if I have the time and the energy to do so.

 

 

Herbie

Refactor! Pro from Developer Express will suggest possible refactorings, help you do them and give you a nice chart of metrics which show which of your methods could benefit from the most work.

 

Simon Jones

stevo_
stevo_
Human after all

http://www.lostechies.com/blogs/sean_chambers/archive/2009/07/31/31-days-of-refactoring.aspx

 

(although personally I've found it a poor- doing the same example but against a different type of member == fail).

page 1 of 1
Comments: 3 | Views: 415
Microsoft Communities