A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearWhat do you consider before refactoring code? - page 1
User InfoPosts
What do you consider before refactoring code?#1
I've got an application that just shipped. Since I wrote it, I've learned about amfphp and propel. Both would be 'nice' to be used in the application but I can't say that it would be required at this point.

What types of things do you consider before you refactor code?

posted date: 2008-12-18 14:26:00


Re: What do you consider before refactoring code?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-18 14:26:01


Re: What do you consider before refactoring code?#3
Have unit tests to check the code after refactoring.

posted date: 2008-12-18 14:28:00


Re: What do you consider before refactoring code?#4
Effort required versus benefit received and where it fits prioritywise with other work.

posted date: 2008-12-18 14:29:00


Re: What do you consider before refactoring code?#5
Good point - by definition you need a way to verify functionality hasn't been broken. I don't think this is the only consideration though.

posted date: 2008-12-18 14:31:00


Re: What do you consider before refactoring code?#6
How maintainable the refactored code will be. Hindsight is 20/20 but with a shipped product, elegant but cryptic design can be a nightmare to maintain. Also, flexibility in the refactored design to allow for feature enhancements is very important.

posted date: 2008-12-18 14:34:00


Re: What do you consider before refactoring code?#7
Create a fork for the current production code base in your source control and do all the refactoring in the experimental branch of the source control.

posted date: 2008-12-18 14:35:00


Re: What do you consider before refactoring code?#8
Unit test would be very nice, but if the code is not covered by unit tests you should have some other means to ensure that you don't break the code. If you can your hands on a copy of production databases, perhaps even some live prod input, you should have a fair chance. In a privious project we actually recorded all ingoing data for 14 days and saved a snapshot of the prod db at the start and end of those 14 days and we were then able to compare the state of the db using the old code and the new code. But Unit tests sure would remove some of the fear :-)

posted date: 2008-12-18 14:47:00


Re: What do you consider before refactoring code?#9
Of course not, but in my opinion this is the most important one.

posted date: 2008-12-18 14:58:00


Re: What do you consider before refactoring code?#10
I sniff the code. If I don't like the smell (in other words, it doesn't smell like me) then I pee all over it until I like it.Since software techniques need cool names like Agile or Design Patterns, I call this Canine Refactoring.After rewriting the code I use it for a while myself, Eating My Own Dogfood.

posted date: 2008-12-18 15:27:00


Re: What do you consider before refactoring code?#11
Should I?Just be cause I can refactor the code does not mean that I should refactor the code. In many, many cases, there are far more important things that need to be done. Like fixing defects. Now, if we're talking about refactoring the code because I am already in that particular block of code and working on it as a part of defect resolution or code maintenance, that's a different story altogether. But refactoring just for the sake of refactoring? That sounds like busywork born out of boredom. Surely you don't have an empty defect list.

posted date: 2008-12-18 15:43:00


Re: What do you consider before refactoring code?#12
I agree refactoring is best done when you're making changes to the code anyway.

posted date: 2008-12-18 16:00:00


select page: « 1 2 »
Copyright ©2008-2017 www.momige.com, all rights reserved.