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 (1)

8
votes
3answers
751 views

BDD: Getting started

I'm starting with BDD and this is my story: Feature: Months and days to days In order to see months and days as days As a date conversion fan I need a webpage where users can enter ...
7
votes
6answers
372 views

How best to handle database refactoring within a team?

We are currently usign a roll-forward approach to DB changes, akin to Migrations, where each developer creates and checks in a script that promotes the latest version of the DB to a new state. ...
13
votes
3answers
447 views

Low impact refactoring and code cleaning of sloppy code while waiting for requirements

I inherited an existing code base for a product that is reprehensibly sloppy. The fundamental design is woefully inadequate which unfortunately I can do little about without a complete refactor (HIGH ...
2
votes
8answers
882 views

Should this code be rewritten or refactored?

There is a module in our telecoms equipment which is written in C. I think the code in this module has a bad smell because it has a number of symptoms: When new features are added to this module, ...
0
votes
3answers
639 views

Are there any good resources for refactoring existing C# code to use LINQ while keeping your tests passing?

I've been teaching myself a little LINQ and an exercise I thought would be useful was to take my existing Project Euler C# code, which I built using Test Driven Development and gradually convert it to ...
12
votes
7answers
4k views

Best way to break down overwhelming code into manageable chunks?

I'm continually becoming overwhelmed by large projects, once they reach a certain level of complexity. Once I reach a certain point in a project, my progress slows to a crawl and I find myself ...
5
votes
2answers
106 views

Simplified Interfaces or Object Abstraction

i've been facing a common situation at work that has happened quite often when handling objects. The situation goes like this: You have to realted classes A and B, class A has an instances of class ...
5
votes
2answers
598 views

Is it possible to refactor inheritance to composition when virtual methods are called inside the base class?

Let's say I have a class called Country and two subclasses called AI and Player. The Country class has a number of virtual methods to allow player-specific or AI-specific behavior. I want to make it ...
14
votes
9answers
1k views

We're not a software company. Is a complete re-write still a bad idea? [duplicate]

I understand the reasoning behind Joel Spolsky's article "Things You Should Never Do, Part I", but I always see it referenced in regards in situations where the end goal is the production of software. ...
7
votes
3answers
5k views

How can I practice design patterns and refactoring in a deliberate way? [closed]

I was reading the book Refactoring to patterns and was wondering how I can get chance to practice the skills, because without deliberate practice on new ways to refactor and use patterns, my skills ...
53
votes
17answers
3k views

How can I make refactoring a priority for my team?

The codebase I work with daily has no automated tests, inconsistent naming and tons of comments like "Why is this here?", "Not sure if this is needed" or "This method isn't named right" and the code ...
25
votes
15answers
1k views

How do I convince my team to use smaller classes/methods?

Disclaimer: I'm a newcomer (this is my third day of work), and most of my teammates are more experienced than me. When I look at our code, I see some code smells and bad engineering practices, like ...
5
votes
3answers
282 views

How to justify framework upgrades

I am looking at how to justify changes to those who control budgets. For example if we have Enterprise Library 4 on some systems and the latest version is 5, is it worth upgrading? How do you justify ...
4
votes
3answers
425 views

Refactoring Bittersweet PHP: How can I make this less painful?

I've just been assigned a large project. The client has had multiple developers across different companies working on their (intended to be) large, MySQL driven eCommerce site. The DB schema is ...
4
votes
3answers
230 views

Small refactorings on a poor codebase?

In the last two years I have worked with a poorly written codebase of nearly 40K lines of code. Over that time I have made many small refactorings to improve it and made some bigger, as time permits. ...
7
votes
5answers
243 views

Is there a name for the concept of a hierarchy of many short methods in a class

A refactoring I commonly do is where I come across a large method such as public void doSomething() { // do First thing doPartA1(); doPartA2(); //now something else ...
2
votes
3answers
304 views

What is the Most Expedient Way to Make Legacy Code Conform to 'The Principle of Proximity'?

On page 242 of Code Complete 2, Steve McConnell touts The Principle of Proximity. Put simply, Mr. McConnell advises programmers to keep related actions together. In my case, the applicable emphasis ...
4
votes
6answers
3k views

What deters developers from using automated refactoring tools? [closed]

I was having a discussion with my colleagues about using the automated refactoring tools in IDEs (Eclipse, NetBeans, IntelliJ, Xcode, Visual Studio, etc) and was surprised that many of them were ...
4
votes
3answers
2k views

When to deprecate and when to delete in Java

As part of a refactoring effort or just ongoing development, a particular method or maybe an entire class may become obsolete in some sense. Java supports the @Deprecated annotation to indicate that ...
9
votes
4answers
1k views

Do I need to upgrade log4j to slf4j [closed]

We are reviewing our JEE web application for some planned refactoring and one of the suggestions is to replace log4j with logback or slf4j The team is not clear on whether we should do this - because ...
39
votes
10answers
34k views

How many lines per class is too many in Java? [closed]

In your experience, what is a useful rule of thumb for how many lines of code are too many for one class in Java? To be clear, I know that number of lines is not even close to the real standard to ...
35
votes
11answers
2k views

Techniques to re-factor garbage and maintain sanity? [duplicate]

So I'm sitting down to a nice bowl of c# spaghetti, and need to add something or remove something... but I have challenges everywhere from functions passing arguments that doesn't make sense, someone ...
6
votes
2answers
470 views

Ruby Koans: depth and usefulness? [closed]

Several people have suggested Ruby Koans to me over just following a book, and this seems like a much better prospect. As there is no question regarding the entirety of Ruby Koans, what do SO users ...
7
votes
5answers
418 views

Method to remove logic from UI

In my less experienced days I added a lot of business logic in the code behind of my .aspx. Now I'm revisiting it I would like to refactor the mess and get it all sorted out. How do I go about this? ...
4
votes
7answers
281 views

Once and only once - with more lines of code

I have an ugly bit of code - essentially iteration over some data structures where the meat of the action was changing, but the iteration code stayed same. The iteration constituted the bulk of code, ...
2
votes
2answers
2k views

What is the best way to work with DAL and BLL?

I'm currently refactoring my DLL and BLL and I need some advice on what is the best way to work with DAL and BLL. My current solution is like this: // DAL class only consists of SQL queries and ...
18
votes
15answers
2k views

Refactoring: Isn't it just a fancy word for clean up your code? [closed]

Before Martin Fowler's book "Refactoring: Improving the Design of Existing Code" came out, we used to call major changes to code "rearchitecture" and minor changes "cleanup". IMO, refactoring ...
5
votes
4answers
174 views

Dealing with bilingual(spoken language) code?

So I've got to work with this set of code here for a re-write, and it's written by people who speak both English and French. Here's a snapshot of what I'm talking about (only, about 4000 lines of ...
27
votes
10answers
2k views

Eliminating Magic Numbers: When is it time to say “No”?

We're all aware that magic numbers (hard-coded values) can wreak havoc in your program, especially when it's time to modify a section of code that has no comments, but where do you draw the line? ...
2
votes
4answers
682 views

outsourcing code review/refactoring [closed]

I have a small project (3000 lines in Python) that I wrote myself; it has no known bugs and has some decent parts, but is largely a mess because of my lack of time. Unfortunately, I have to be the one ...
10
votes
3answers
1k views

Best Practices for Renaming, Refactoring, and Breaking Changes with Teams

What are some Best Practices for refactoring and renaming in team environments? I bring this up with a few scenarios in mind: If a library that is commonly referenced is refactored to introduce a ...
23
votes
18answers
2k views

Why write clean, refactored code? [duplicate]

This is a question I've been asking myself for a long time. Thought of throwing out it to you. From my experience of working on several Java based projects, I've seen tons of codes which we call ...
7
votes
1answer
1k views

Looking for statistics on automated testing, continuous integration and refactoring usage

Are there any credible sources of information on the adoption of agile techniques like automated testing, continuous integration and refactoring? Of those that are using unit testing, how many ...
38
votes
8answers
2k views

Code maintenance: keeping a bad pattern when extending new code for being consistent, or not?

I have to extend an existing module of a project. I don't like the way it has been done (lots of anti-pattern involved, like copy/pasted code). I don't want to perform a complete refactor for many ...
1
vote
3answers
403 views

How to convince a client to switch to a framework *now*; also examples of great, large-scale php applications

I'm about to start working on a very ambitious project that, in my opinion, has some great potential for what concerns the basic concept and the implementation ideas (implementation as in how this ...
7
votes
7answers
467 views

How to refactor while keeping accuracy and redundancy?

Before I ask this question I will preface it with our environment. My team consists of 3 programmers working on multiple different projects. Due to this, our use of testing is mostly limited to very ...
25
votes
12answers
1k views

Colleague unwilling to use unit tests “as it's more to code”

A colleague is unwilling to use unit tests and instead opting for a quick test, pass it to the users, and if all is well it is published live. Needless to say some bugs do get through. I mentioned ...
13
votes
3answers
2k views

How do you navigate and refactor code written in a dynamic language?

I love that writing Python, Ruby or Javascript requires so little boilerplate. I love simple functional constructs. I love the clean and simple syntax. However, there are three things I'm really bad ...
15
votes
10answers
1k views

How to fix the copy/paste-pattern?

Where i work, people (consultants) feel pressed to release features as fast as possible. So instead of spending too much time on thinking about how to do things the right way or because they don't ...
10
votes
7answers
284 views

What approaches can I take to lower the odds of introducing new bugs in a complex legacy app?

Where I work I often have to develop (and bug fix) in an old system (.NET 1) whos code is complete spaghetti - with little thought given to variable names, program structure nor comments. Because of ...
10
votes
2answers
443 views

How to organize repetitive code?

My team creates a lot of one-off web forms. Most of these forms just send an e-mail, and a few do a simple database write. Right now, each form lives in its own separate solution in Visual Studio ...
2
votes
5answers
318 views

how to evaluate own project

I am working on a open source project in pure C, that I have started some time ago, but only recently found time to add some features. I can clearly some weaknesses of my old design, so I am trying to ...
5
votes
4answers
591 views

Code cleanup methods and/or code coverage tools

I have an application at work, which I started work on about 7 years ago. This was my first engagement in ASP.NET web applications, and coming from a Win32 background I had a hard time adjusting. ...
9
votes
5answers
2k views

How to approach refactoring an existing web application?

I've been reading and thinking a lot lately, and I've come to the conclusion that I maybe I should rethink my web development strategy. I'm doing a lot of on-the-fly programming, and in the 2 years ...
27
votes
6answers
1k views

What payoffs have you seen from taking care of technical debt?

This article on technical debt has some good points, including: Working on the "technical matters" works best when it is driven by stories. The code base is probably in need of work everywhere, ...
11
votes
4answers
327 views

What are good approaches to cleaning up old projects?

I've got some software that I wrote around 2 years ago and needs some features added to it. I've realised that it's in an awful mess, and I have the urge to move everything around, tidy up, etc. I've ...
6
votes
3answers
1k views

.Net Best Practices : Common Bugs Introduced By Refactoring, Carelessness, and Newbies

What are the common bugs introduced by refactoring, carelessness, and newbies? I would like to request the experienced programmers here to share their experience and list the bugs they used to ...
21
votes
12answers
646 views

Refactor or Concentrate on Completing App

Would you refactor your app as you go or focus on completing app first? Refactoring will mean progress of app app will slow down. Completing app will mean you get a possibly very hard to maintain app ...
10
votes
7answers
685 views

Best supporting argument for refactoring [duplicate]

Currently I am working on a code best described as C code living in C++ body. However I haven't been able to convince power that be to re-factor on ground of ease of maintenance. What in your ...
5
votes
3answers
744 views

Refactoring code smells in ASP.NET Web Forms Code Behind Files: Is it risky? Is it wise? Is it a waste of time?

Given a long method with Pac-Man ifs, would it be wise to: Break down code blocks into regions. Then refactor code blocks into methods. Or would it be best to leave it alone? Would it be risky? ...