How to refactor code for improved programming...

stoymigo

Senior Member
Joined
Dec 11, 2008
Messages
975
Reaction score
26
I'm currently doing programming on the side and the code I have to look at has lots of repetition which I plan to reduce and to make the code more readable.

I talk about repetition because I've been burned by it at my workplace...I created duplicate code for parts of the program and when a bug came through the maintenance was doubled which took hours.

I know you call this the DRY principle, do you have any other tips/links about improving code so one doesn't have to feel like starting all over again if I look at it in a weeks time.
Thanks
 
I am a heavy user of Resharper from www.jetbrains.com. It helps with syntax and structure a lot, but design comes with experience.

Never ever ever ever write duplicate code.

Don't feel alone though. You're not the first to do this. Just learn from it and all is good ;)
 
Duplication is bad practice. Try to greate generic functions/methods that handle variance through parameters.
 
Duplication is bad practice. Try to greate generic functions/methods that handle variance through parameters.

In my world, the use of function would sit along side procedure - not method. Method encompasses both.

You mention generics however, so assuming you referring to c#?
 
Top
Sign up to the MyBroadband newsletter
X