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
195 views

Should a new class refactored out of an existing one have history pointing back to it's progenitor

If I split one class into two classes should both classes have history in source control tracing back to the original class that contained both; or should the new class be added as a new file without ...
6
votes
3answers
599 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 ...
6
votes
2answers
443 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 ...
6
votes
1answer
418 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 ...
5
votes
3answers
2k views

Should I refactor a F class from code climate? [closed]

According to code climate (static quality analysis), a class is F, aka the worst mark you could be granted. I did submit a pull request to rearrange it here Which has been refused because the new ...
5
votes
5answers
722 views

Martin Fowler's Refactoring book: switch statement is using other object's data, why is that bad ? A deeper explanation is sought for.

In the code sample below the Rental object is using Movie's fields to do a switch statement. Martin says : this is a bad idea but he does not give any deeper explanation as to why ? Of course, you ...
5
votes
5answers
207 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 ...
5
votes
3answers
335 views

How should I go about “overhauling” a large legacy application? [duplicate]

Possible Duplicate: I’ve inherited 200K lines of spaghetti code — what now? For my next project, I've been tasked with "overhauling" a large legacy web application with many parts. It is a ...
5
votes
3answers
249 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 ...
5
votes
4answers
167 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 ...
5
votes
3answers
504 views

CTO has left — codebase is a huge kludge, any advice on how to manage/handle/damage control? [closed]

I began work at a company 2 months ago as a PHP developer. I stepped in to somewhat of a kludge, but I've yet to find a company that isn't... The development stable is currently two developers ...
5
votes
1answer
166 views

How to design an algorithm-heavy and object-light application

Other than vertices, edges, faces and meshes, my geometry processing project/application has only about half a dozen other entities such as curves on surfaces. However the majority of my code is ...
5
votes
7answers
153 views

Can initial inefficient solutions INSPIRE better ones and thus lead to faster problem solving?

When faced with writing an algorithm to solve a small project/problem is it better to come up with pseudo code that isn't efficient/optimum but solves the problem and then try to use the inefficient ...
5
votes
1answer
381 views

Reasoning to wait until third time in the Rule of Three?

I just came across the article "Rule of Three" in wikipedia Rule of three is a code refactoring rule of thumb to decide when a replicated piece of code should be replaced by a new procedure. It ...
5
votes
1answer
758 views

How to unit test large legacy systems? [duplicate]

Possible Duplicate: Best practices for retrofitting legacy code with automated tests When working in large legacy systems (large systems with no unit testing ever) I often come across ...
5
votes
3answers
196 views

When is 'cloning', rather than reusing, a module acceptable design solution?

For this question, I'll give an example module to facilitate the discussion, Let's say the module is a calculation engine, It currently servers its purpose for its current audience. The requirement is ...
5
votes
2answers
123 views

How to keep track of links pointing to existing web applications in an Intranet?

At my new place of employment we have a Intranet solution containing multiple web applications hosted in IIS. Outside of the development department other departments either source or create other ...
5
votes
3answers
158 views

Engineering a better solution, coming from existing codebase [duplicate]

The Code I have high-business-value daily-used-by-customer software that is written in PHP and spans approximately 600K lines of code. Customer for a long time needs, wants, and demands new features ...
5
votes
3answers
527 views

Starting on a large project, should I split it into more concise parts?

Background: Currently an intern at a company and working on repurposing older programs (still in use, but for different departments) for use in testing new hardware. The new hardware is different in ...
5
votes
2answers
1k views

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

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 ...
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 ...
5
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 ...
5
votes
2answers
250 views

How should I refactor switch statements like this (Switching on type) to be more OO?

I'm seeing some code like this in our code base, and want to refactor it: (Typescript psuedocode follows): class EntityManager{ private findEntityForServerObject(entityType:string, ...
5
votes
2answers
99 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
1answer
377 views

Music Notation Editor - Refactoring view creation logic elsewhere

Let me preface by saying that knowing some elementary music theory and music notation may be helpful in grasping the problem at hand. I'm currently building a Music Notation and Tablature Editor (in ...
5
votes
5answers
1k 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 ...
4
votes
3answers
547 views

How should I start refactoring my mostly-procedural C++ application?

We have a program written in C++ that is mostly procedural, but we do use some C++ containers from the standard library (vector, map, list, etc). We are constantly making changes to this code, so I ...
4
votes
7answers
389 views

Should all development, including refactoring work, be accompanied by a tracking issue?

The debate: Should all development, including refactoring work, be accompanied by a tracking issue? (in our case, Jira) The common ground: Our primary goal is quality. A working product, every ...
4
votes
3answers
580 views

Is it Typical for Large Software Companies to Not Document or Refactor Code? [closed]

I have begun working at a large software company and was assigned to a project that is over a million and a half lines of code. It's part of a program suite that is sold to clients (not an in-house ...
4
votes
7answers
278 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, ...
4
votes
4answers
601 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 ...
4
votes
3answers
1k 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 ...
4
votes
3answers
502 views

Is there a term for reusing code by retyping it?

I built a prototype ("one to throw away") a while ago, and I'm rebuilding it now as an alpha. My goodness, it's been worth it. I reused some of the prototype code by copy-pasting then modifying it, ...
4
votes
2answers
2k views

Refactoring c++ [closed]

I know that there are some other questions about c++ refactoring, but none satisfies my needs. I have a background in java and python programming, but now I'm approaching C++. I've read (and ...
4
votes
2answers
561 views

How do I handle having so many SQL queries?

I have an MVC3 project that uses SQL Server. I use data from the SQL database all the time and I often find that I'm reusing/duplicating some SQL queries. I thought I'd solve this problem by creating ...
4
votes
3answers
397 views

Renaming long named method in C# [closed]

I'm working on a project where exist one method with title string ValidateNewPasswordExpireCurrentPasswordAndCreateNewPassword(...) I'm sure the method name must be changed. But can't found good ...
4
votes
3answers
232 views

Is an Inner Function Justified in this Situation

I'm new to the functional programming concepts in C#, but I have some experience with higher order functions via Haskell, Scala, Python and Ruby. I'm currently going through an old .NET 2.0 codebase ...
4
votes
4answers
353 views

How to avoid excessive method overloading?

We have quite a lot of places in the source code of our application , where one class has many methods with same names and different parameters. Those methods always have all the parameters of a ...
4
votes
3answers
361 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
2answers
176 views

Refactoring a live system that is tightly coupled with improper data models and business logic in the front-end

Scenario This was a project that I once had to maintain. After reading Working Effectively with Legacy Code, I started to think how I would refactor this system in a live environment, if I had to ...
4
votes
4answers
180 views

How to implement isValid correctly?

I'm trying to provide a mechanism for validating my object like this: class SomeObject { private $_inputString; private $_errors=array(); public function __construct($inputString) { ...
4
votes
3answers
252 views

How to avoid programmers duplicating code [duplicate]

While I know in a perfect world where a greenfield application was scoped out from day one with great BRD's and a competent development lead constantly reviewed code by their underlings to avoid this, ...
4
votes
7answers
712 views

Naming guard clauses that throw exceptions

I have a function evaluate() that parses a String for some variables and replaces them with their corresponding value: public String evaluate() { String result = templateText; for ...
4
votes
3answers
224 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. ...
4
votes
5answers
2k views

What deters developers from using automated refactoring tools?

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
2answers
1k views

Is it possible to avoid enormously big switch in that case? [duplicate]

I'm writing a simple chess-related code with intention to write it clearly (performance doesn't matter at all). And this method I have doesn't look clean to me at all: public static Piece ...
4
votes
3answers
181 views

Is there a resource that explains the benefits of layered programming?

Let's say we have a winform application with a buttonclick event. The buttonclick handles everything from the UI configuration to the database call and data manipulation. So you end up with a method ...
4
votes
2answers
195 views

How do you create documentation when there is none? [duplicate]

I have recently inherited a large, legacy system with a complex codebase that has a lack of documentation. I'm the sole internal developer embedded with the core users, taking some responsibility from ...
4
votes
2answers
289 views

What is the right way to group this project into classes?

I originally asked this on SO, where it was closed and recommended that I ask it here instead. I'm trying to figure out how to group all the functions necessary for my project into classes. The goal ...
4
votes
3answers
1k views

Is it okay to call a model method in my view?

In the interest of keeping my Controller's skinny, I put a headline method in a Model. # My Model class Property def headline "#{name} | #{address}" end end (Then, Property Controller for ...