Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.

learn more… | top users | synonyms

6
votes
3answers
833 views

How to explain your non-programmer boss you need to refactor a whole site?

First of all, is not a programming matter, is a programmer afair. I'm the new web programmer in my company. I'm here just for 2 weeks. And they want me to teach Wordpress, configure & install it, ...
16
votes
8answers
1k views

When to refactor

I've read through most of Fowler's Refactoring book and have refactored many applications in my past big and small. One of the harder things I find to teach is "when" to refactor. I tend to do this ...
81
votes
8answers
4k views

What is the most effective way to add functionality to unfamiliar, structurally unsound code? [duplicate]

This is probably something everyone has to face during the development sooner or later. You have an existing code written by someone else, and you have to extend it to work under new requirements. ...
2
votes
2answers
638 views

Right design pattern to use StopWatch class

I have to measure execution time for a blocks of code. I had implemented simple StopWatch class like http://www.goldb.org/stopwatchjava.html. If I will invoke methods of StopWatch class directly ...
36
votes
11answers
1k views

How do people doing TDD handle loss of work when doing major refactoring

For a while I have been trying to learn to write unit tests for my code. Initially I started out doing true TDD, where I wouldn't write any code until I'd written a failing test first. However, I ...
3
votes
2answers
541 views

What are some good small-scale refactoring tests?

I'm looking to test potential candidates on their ability to develop concise, reusable code. I feel like a good test of that skill would be to give them a very small scale application or class ...
3
votes
2answers
353 views

Methods to rewrite a program [duplicate]

Possible Duplicates: How to approach refactoring an existing web application? Starting a coherent architecture in a legacy application We have a fidelity system running on the company I ...
6
votes
1answer
359 views

Refactoring an existing MVC codebase to remove business logic & data access from the Controllers

Product I've inherited has the following composition: MVC web site where the controllers make calls to Repositories to get, insert and update objects retrieved that are defined in the: Data ...
10
votes
3answers
664 views

What are good ways to organize input files (Makefiles, SConstruct, CMakeLists.txt, etc.) to build automation software?

One thing I like to do with my code is make sure that it's refactored into manageable pieces. However, when it comes to building the software, I find that whatever build automation software I end up ...
12
votes
5answers
579 views

How does one determine whether or not to rewrite poorly-designed code? [duplicate]

Possible Duplicate: When is a BIG Rewrite the answer? I'm on a small team that's been handed a poorly-written, half-finished 2D Java game. Our objective is to do as much as we can to make ...
3
votes
2answers
294 views

What are the three main technologies for a redesign of a COBOL legacy system

There exists an application that reports financial data of a bank to a national bank (all located in Europe). It is a legacy system that is written mainly in COBOL. Only the user interface is written ...
12
votes
7answers
793 views

After writing code, why do I feel that “I would have written better” after some time? [closed]

I have been working on my hobby project in C++ for more than 2 years. Whenever I write a module/function, I code it with lot of thinking. Now see the problem, do { --> write the code in module ...
4
votes
1answer
191 views

Should I refactor this rails application?

I have taken over the code base for a ruby-on-rails application which relies very heavily on ActiveRecord callbacks to perform domain rules. The application can be compared to a bank application, ...
6
votes
1answer
320 views

General approach to re-factoring an large, very badly written legacy system [duplicate]

Possible Duplicate: Techniques to re-factor garbage and maintain sanity? What is a good way to refactor a large, terribly written code base by myself? Really open question here. I'm not ...
4
votes
5answers
796 views

Example bad code project to motivate refactoring / good design [closed]

This is sort of the opposite of Is there an open-source project that can be an example of well-written code?. I am teaching software engineering to undergraduates and I would like a blob of object ...
3
votes
1answer
334 views

Splitting Logic, Data, Layout and “Hacks”

Sure, we all heard of programming patterns such as MVVM, MVC and such. But that isn't really what I'm looking into as Layout, Data and Logic is already pretty much split up (XML-Layout markup, ...
2
votes
1answer
327 views

Most frequently used design patterns in refactoring (my example) [closed]

I've been doing quite a lot of refactoring of C++ and C# code recently, and found that 90% of the patterns I use are: Template method Factory Singleton Are these generally the most commonly used ...
13
votes
7answers
843 views

Should I change author name in class file if I make more than 80% changes?

I am refactoring existing set of java test classes for automated UI tests. At times I end up in making massive changes in class file or completely revamping it. This makes me think that when I am ...
3
votes
2answers
326 views

How to fix very bad code? [duplicate]

Possible Duplicates: How do you dive into large code bases? How do I handle refactoring that takes longer than one sprint? I have 2 files that cover 5000 lines of code. I have been ask to ...
3
votes
0answers
341 views

What is a good way to refactor a large, terribly written code base by myself? [duplicate]

Possible Duplicate: Techniques to re-factor garbage and maintain sanity? I have a fairly large PHP code base that I have been writing for the past 3 years. The problem is, I wrote this code ...
0
votes
3answers
358 views

Do you have a find/replace list of C/C++ code improvements that doesn't cause side effects?

Time after time you have to work with code that's not as safe as you would like it to be. Either that's someone elses code, or something you wrote at 3am 5 years ago, but it happens. And in those ...
-2
votes
1answer
83 views

How do you solve large dependencies among files?

So basically I make several programs. Of course one program often used code from another. So I have my own personal "library" Well, I do write jerk codes. Then When I open a project, the project will ...
3
votes
4answers
159 views

Does not testing internals entail diligent refactoring and/or rely on developer talent?

I'm not asking here what the arguments are for/against testing internal methods (though I'll restate some, and don't mind hearing others). My questions relate to the implications of only testing ...
10
votes
8answers
446 views

What can be the cause of new bugs appearing somewhere else when a known bug is solved?

During a discussion, one of my colleagues told that he has some difficulties with his current project while trying to solve bugs. "When I solve one bug, something else stops working elsewhere", he ...
6
votes
3answers
557 views

Programming standards and principles to become better programmer [closed]

I am a c# developer. I have always been interested in increasing my skills and knowledge and trying to pickup new technology. However now I want to enhance my knowledge in Programming standards and ...
1
vote
3answers
186 views

Should controls on a form be prepared in a separate class?

I have a form with several controls on it. Every control has to be declared in the class, formatted in the constructor (-size, location, event subscription etc), and its event-handlers declared, ...
10
votes
6answers
1k views

Self-documenting code vs Javadocs?

Recently I've been working on refactoring parts of the code base I'm currently dealing with - not only to understand it better myself, but also to make it easier for others who are working on the ...
27
votes
5answers
6k views

What are the key points of Working Effectively with Legacy Code?

I've seen the book Working Effectively with Legacy Code recommended a few times. What are the key points of this book? Is there much more to dealing with legacy code than adding unit/integration ...
4
votes
4answers
568 views

Role of “Refactoring” in good programming pratices?

I have learned in Agile Development that: Refactoring is the process of clarifying and simplifying the design of existing code, without changing its behavior. I have heard about some GUI ...
11
votes
6answers
2k views

How to refactor code to some common code?

Background I'm working on an ongoing C# project. I'm not a C# programmer, primarily a C++ programmer. So I was assigned basically easy and refactoring tasks. The code is a mess. It's a huge project. ...
19
votes
4answers
1k views

How to drastically improve code coverage?

I'm tasked with getting a legacy application under unit test. First some background about the application: It's a 600k LOC Java RCP code base with these major problems massive code duplication no ...
5
votes
2answers
874 views

Are there any good examples of open source C# projects with a large number of refactorings? [on hold]

I'm doing research into software evolution and C#/.NET, specifically on identifying refactorings from changesets, so I'm looking for a suitable (XP-like) project that may serve as a test subject for ...
2
votes
2answers
282 views

How can I refactor client side functionality to create a product line-like generic design?

Assume the following situation similar to that of Stack Overflow: I have a system with a front-end that can perform various manipulations on the data (by sending messages to REST back-end): Posting ...
16
votes
12answers
862 views

Is it ok to write a quick software programme and then refactor it? [duplicate]

In my team, people have tendency to develop a POC (which is very close to actual deliverable in terms of features) which takes good amount of time to be created. And then spend a significant time to ...
3
votes
7answers
265 views

How best to prevent having to revisit a change after check in

Normally what happens is that I work on something for a while and then when I am done I check it in(After the test/review process of course). Sometimes I have to go back and fix something that I got ...
7
votes
4answers
300 views

How do I do TDD when expected behaviour is to be changed?

I've been doing TDD with a project I'm working on, and I have quite a large number of tests. I have quite a few automated tests around restrictions enforced in code, making sure things that shouldn't ...
27
votes
9answers
2k views

How clean should new code be? [duplicate]

I'm the lead designer in our team, which means I'm responsible for the quality of the code; functionality, maintainability and readability. How clean should I require my team members' code to be if ...
9
votes
8answers
422 views

Refactoring or upgrading databases to handle new features

Several responses to a database schema question, suggested an additional table to normalize a database for a feature that is not part of the current requirements (A UserDepartment table to allow for a ...
2
votes
3answers
187 views

When does switching to a framework mid-project make sense?

Some of my friends and I started a PHP project some weeks ago. In the beginning, I suggested we use a PHP framework such as CodeIgniter or Zend. But my friends wanted to start clean and without the ...
2
votes
3answers
402 views

Creating public API definition for existing application

Let's say there's a successful open source application (written in PHP if it matters), which provides its users with multiple ways to extend it (think about something like Drupal or Wordpress, lots of ...
5
votes
1answer
1k views

How do I structure a larger Flask application?

I have a relatively simple web application that is written in Python using the Flask microframework. I've really enjoyed Flask's ease of use, however, as the app has grown larger it has started to ...
13
votes
7answers
1k views

How do you manage refactoring with a large code base and many developers?

I would like to prevent a situation where two developers refactor the same code simultaneously without talking about it first, probably using a tool of some kind, maybe an Eclipse plug-in. Can you ...
12
votes
5answers
382 views

Resolving merge conflicts due to refactoring

I got involved in a discussion recently on how to handle refactoring in general (which is an interesting topic in itself). Eventually the following question was brought up: How does one handle merge ...
17
votes
7answers
647 views

What can you do about the quality of existing integration and unit tests while being the new guy in a team ?

A recurring theme that I came across in my career is being the new developer to arrive in a team, and quickly having an inherent distrust of the existing unit and integration test suites. During the ...
10
votes
5answers
605 views

Should you refactor existing code that is not broken in a project focused on new features?

Given a small project that aims to add new functionality to application, the changes introduced touch some existing code, involving updating these in certain areas. During implementation, I've found ...
15
votes
10answers
643 views

suggesting large changes/a rewrite as an intern

The context: it's an internal project (that I don't think a lot of people use) it's old we're updating it The issues: it abuses the mvc framework (no use of models, business logic in views, etc) ...
10
votes
2answers
214 views

Are there any good tools for visualizing refactoring work?

Many of my co-workers take pride in writing complex algorithms and programs, ones which take significant time to completely grok. I (strongly) tend towards the opposite end. I'm proud when I write a ...
12
votes
4answers
1k views

How to commit in-progress refactoring?

So, I have this big project, which is in the process of being refactored by me. I am changing a lot of stuff, so there is no chance to get it to compile some time soon. I am living in a special git ...
11
votes
2answers
691 views

Adding unit tests to a legacy, plain C project

The title says it all. My company is reusing a legacy firmware project for a microcontroller device, written completely in plain C. There are parts which are obviously wrong and need changing, and ...
45
votes
16answers
3k views

How do I handle refactoring that takes longer than one sprint?

I work with a code base that is over 500K lines of code. It is in serious need of refactoring. There have been refactoring efforts identified that will take longer than the normal two week sprint. ...