Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.
4
votes
1answer
216 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 ...
2
votes
2answers
346 views
How Visual Studio could help to avoid duplicating code?
I work within a team of developers. Everyone is making their changes without carrying too much if the same thing is already implemented in the codebase. This leads to classes constantly growing and to ...
14
votes
8answers
570 views
Quantifying the value of refactoring in commercial terms
Here is the classic scenario; Dev team build a prototype. Business mgmt like it and put it into production. Dev team now have to continue to deliver new features whilst at the same time pay the ...
3
votes
1answer
166 views
Refactoring obscurely commented code
In refactoring code, I came across code that had comments. Looking closer at the comments, I could see that the code was clearly not doing what the comments said.
Without access to the coder nor ...
6
votes
6answers
465 views
Refactoring and Open / Closed principle
I have recently being reading a web site about clean code development (I do not put a link here because it is not in English).
One of the principles advertised by this site is the Open Closed ...
8
votes
4answers
288 views
Rapid prototyping and refactoring
Sometimes when I start a small project (like an android app), I don´t know which approach will work out at the end, and I just go for one approach and give it a try. But if I never used this approach ...
4
votes
4answers
146 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) {
...
2
votes
1answer
435 views
Recovering an anemic domain model into a multitier architecture
I have spent the past several days learning about domain driven design and attempting to apply it to a current project. I decomposed the problem domain into the canonical logical components: domain, ...
0
votes
1answer
111 views
Persuading management that refactoring code is a good idea [duplicate]
Possible Duplicate:
Best supporting argument for refactoring
Has anyone got any tips for persuading management that refactoring code is a good idea ? I was asked something like
"After ...
3
votes
1answer
97 views
Naming a class that processes orders
I'm in the midst of refactoring a project. I've recently read Clean Code, and want to heed some of the advice within, with particular interest in Single Responsibility Principle (SRP).
Currently, ...
3
votes
3answers
331 views
How to deal with almost the same enums?
I need to define enums in several classes. The majority of fields are the same in all of the enums. But one has one or two more fields, another has fewer fields. Now I wonder what is the best way to ...
0
votes
3answers
250 views
Introduce unit testing when codebase is already available [duplicate]
Possible Duplicate:
Best practices for retrofitting legacy code with automated tests
I've been working on a project in Flex for three years now without unit testing. The simple reason for ...
3
votes
1answer
322 views
Replacing out parameters with struct
I'm encountering a lot of methods in my project that have a bunch of out parameters embedded in them and its making it cumbersome to call the methods as I have to start declaring the variables before ...
4
votes
2answers
219 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 ...
0
votes
2answers
223 views
Breaking up a large PHP object used to abstract the database. Best practices?
Two years ago it was thought a single object with functions such as $database->get_user_from_id($ID) would be a good idea. The functions return objects (not arrays), and the front-end code never ...
3
votes
6answers
612 views
What to do when you inherit an unmaintainable codebase? [duplicate]
Possible Duplicate:
Techniques to re-factor garbage and maintain sanity?
I've inherited 200K lines of spaghetti code — what now?
I'm currently working at a company with 2 other ...
4
votes
3answers
799 views
How do I break down and plan a personal programming project? [closed]
I've just started a programming job where I'm applying my 'How to code' knowledge to what I'm being taught of 'How to Program' (They are different!). As part of this, I've been taught how to capture ...
6
votes
7answers
368 views
Is there such thing like a “refactoring/maintainability group” role in software companies?
So, I work in a company that does embedded software development, other groups focus in the core development of different products' software and my department (which is in another geographical ...
6
votes
3answers
149 views
What do I need to learn to decide on rename/recompile source package names because of company rebranding?
My company is currently at a rebranding process and the brand names have been used in the sources' package names but these names are only visible to developers who maintain this code so nobody from ...
4
votes
3answers
414 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 ...
9
votes
4answers
417 views
How to unit test a function that is refactored to strategy pattern?
If I have a function in my code that goes like:
class Employee{
public string calculateTax(string name, int salary)
{
switch (name)
{
case "Chris":
...
13
votes
7answers
729 views
Using functions as a way to stylize
Have you ever broken up a large function into smaller functions knowing that those smaller functions will not be called by more than one caller? The primary purpose of a function is to promote code ...
8
votes
3answers
228 views
How do you break out of the role of a code maintainer? [closed]
In my last three jobs, I was a code maintainer. In all three cases, I was hired after the majority of the code for the project was already written.
I'm a self taught programmer. Before I ever started ...
4
votes
3answers
202 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 ...
6
votes
4answers
604 views
How to deal with code reuse philosophy?
I constantly find myself thinking about code reuse when starting a new project.
To what extent should I make my code reusable?
Should I limit it to the application scope or should I make it reusable ...
3
votes
2answers
187 views
How long does one have to wait to consider design change in code?
I had a few days ago. I was having trouble with threads. Had lots of questions asked on StackOverflow and honestly for the first time I did not get the answer I was looking for. Finally, I decided to ...
5
votes
6answers
524 views
What are the practical ways to implement the SRP?
Simply what are the practical techniques people use to check if a class violates the single responsibility principle?
I know that a class should have only one reason to change, but that sentence is ...
32
votes
4answers
1k views
What is the term for this type of refactoring
I am sure there is a term for the following bit of refactoring, but I can't remember it and my Google-fu is failing me!
The refactor moves if statements to where they are going to have most impact, ...
7
votes
4answers
136 views
Controllers and re-factoring for maintainability / sensibility
I have read many posts similar to this on the site: however I still am questioning what is best in my situation (also the answers are contradicting from question to question).
I have a website ...
13
votes
7answers
657 views
How to justify code refactoring time?
Have a very large project more than 70k LOC.
The project definitely needs some code refactoring in Core Framework and in other parts as well. There was NO time set in the beginning of the project for ...
0
votes
1answer
99 views
How far should I expose this status enum?
I wrote a little app to manage an arbitrary series of tasks (e.g., call a SQL sproc and capture out-vars, run another app, run an SSIS package) with dependencies between tasks. Each task has a status ...
3
votes
2answers
87 views
Handling fast growing multi-function services
My team has been developing a web business application for more than a year. It started quite small, but now it is growing bigger and bigger. I think it's time for refactoring.
Looking at the code, I ...
3
votes
2answers
547 views
Refactor class (extract methods) in a main / helper classes
Simply spoken, one of my c# classes got too big and I'm currently splitting this class in several subclasses by clustering semantically related methods (actually actions, which do side effects).
So, ...
5
votes
3answers
277 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 ...
7
votes
2answers
393 views
How do you call the process of taking a part of a function and making an individual function of it?
I know there was a technical term for this. I'm just can't remember what it was.
If the title needs clarification, here is what I mean; If this is the old code:
Result foobar(Param1,Param2,Param3) {
...
3
votes
1answer
99 views
How should I write new code when the old codebase and the environment uses lots of globals in PHP
I'm working in the Wordpress environment which itself heavily relies on globals and the codebase I'm maintaining introduces some more. I want this to change and so I'm trying to think how should I ...
2
votes
1answer
332 views
How to refactor a method which breaks “The law of Demeter” principle?
I often find myself breaking this principle (not intentially, just through bad design). However recently I've seen a bit of code that I'm not sure of the best approach.
I have a number of classes. ...
2
votes
7answers
482 views
After how much line of code a function should be break down?
While working on existing code base, I usually come across procedures that contain Abusive use of IF and Switch statements. The procedures consist of overwhelming code, which I think require ...
5
votes
7answers
2k views
Use constructor or setter method?
I am working on a UI code where I have an Action class, something like this -
public class MyAction extends Action {
public MyAction() {
setText("My Action Text");
...
66
votes
19answers
4k views
Is it ok to replace optimized code with readable code?
Sometimes you run into a situation where you have to extend/improve some existing code. You see that the old code is very lean, but it's also difficult to extend, and takes time to read.
Is it a good ...
2
votes
4answers
148 views
Good design for class with similar constructors
I was reading this question and thought that good points were made, but most of the solutions involved renaming one of the methods. I am refactoring some poorly written code and I've run into this ...
3
votes
3answers
322 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
1answer
353 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 ...
1
vote
2answers
168 views
Setting variable in constructor or within method
I have a class which contains two methods.
These methods add & remove an object to a datastore.
The class which contains these methods has a no arg constructor but each of the two methods takes ...
0
votes
1answer
147 views
Reorganizing code based on dependencies
I'm wondering if there is a tool that can generate a dependency graph between C language object files and then analyze how to turn that graph into a DAG by modifying code that creates cycles, moving ...
11
votes
6answers
923 views
A defense for boilerplate?
To me, boilerplate code is obviously bad. However I've met a developer who displays resistance in any attempt to reduce boilerplate. I realized I didn't have a readily formed, well thought out ...
12
votes
6answers
2k views
Refactoring Switch Statements and is there any real use for Switch Statements at all?
I was reading this article and was wondering, do we get rid of all switch statements by replacing them with a Dictionary or a Factory so that there are no switch statements at all in my projects.
...
5
votes
3answers
165 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
3answers
485 views
Replace Type Code with Class (From Refactoring [Fowler])
This strategy involves replacing the likes of this:
public class Politician
{
public const int Infidelity = 0;
public const int Embezzlement = 1;
public const int FlipFlopping = 2;
...
0
votes
2answers
100 views
How should I refactor so that responsibility for a geocoding service is shared appropriately?
First, some background. I have an application that requires the use of several external geocoding providers which I don't control. It uses a central service layer inside the application to dispatch to ...