Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.
1
vote
0answers
65 views
Thoughts on refactoring a generic DAO
I have designed a generic DAO in Java and am having confusion about whether to refactor it to different design or not.
PS Don't say to use already existing 3rd person framework. I know there are some ...
3
votes
3answers
236 views
Is it Typical for Large Software Companies to Not Document or Refactor Code? [on hold]
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 ...
1
vote
1answer
32 views
Refactoring from Python to Ruby with a BSD v3 license?
There is a project that is written in python which works great and is under the BSDv3 license. I wanted to use it as a base template for a ruby project instead of starting from scratch. I'd be ...
8
votes
5answers
620 views
Avoid too complex method - Cyclomatic Complexity
Not sure how to go about this method to reduce Cyclomatic Complexity. Sonar reports 13 whereas 10 is expected. I am sure nothing harm in leaving this method as it is, however, just challenging me how ...
11
votes
5answers
392 views
Code repetition vs multi responsible method
I try to follow the Single Responsibility Principle (SRP) and also to omit Code Repetitions. However there are often places where there are code repetitions that are nothing more than code blocks of ...
0
votes
1answer
61 views
Get entities ids from two similar collections using one method
I've got two lists:
List<Integer, ZooEntity> zoos;
List<Integer, List<ZooEntity>> groupOfZoos;
These operations will return collections of values:
Collection<ZooEntity> cz ...
9
votes
2answers
295 views
Is spreading code with refactoring comments a good idea?
I am working on a "spaghetti-code" project, and while I am fixing bugs and implementing new features, I also do some refactoring in order to make the code unit-testable.
The code is often so tightly ...
0
votes
0answers
41 views
Refactoring this code that produces a reverse-lookup hash from another hash
This code is based on the idea of a Form Object
http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/
(see #3 if unfamiliar with the concept).
My actual code in ...
2
votes
2answers
199 views
Why delete method/field/function refactoring doesn't exist in Eclipse?
An operation in an interface is obsolete so I decided to delete it.
It seems that there is no automatic support for such a "refactoring" in Eclipse.
For me is a refactoring operation since the ...
0
votes
1answer
92 views
unit level testing, agile, and refactoring [duplicate]
I'm working on a very agile development system, a small number of people with my doing the vast majority of progaming myself.
I've gotten to the testing phase and find myself writing mostly ...
1
vote
1answer
91 views
Proper library for enums
I'm trying to refactor some code such that the display is separate from the implementation, and I'm not sure where to put the existing enums.
My project is currently structured as follows:
...
7
votes
3answers
280 views
How to refactor when all your development is on branches?
At my company, all of our development (bug fixes and new features) is done on separate branches. When it's complete, we send it off to QA who tests it on that branch, and when they give us the green ...
9
votes
5answers
1k views
How to refactor an OO program into a functional one?
I'm having difficulty finding resources on how to write programs in a functional style. The most advanced topic I could find discussed online was using structural typing to cut down on class ...
2
votes
2answers
176 views
Refactoring two classes from third-party library that could have extended a base class
I have two Classes, with very similar behaviors, both from a third party library.
Both needs to be populated with some value object and sent to specific queues in order for logging. Please note both ...
19
votes
3answers
1k views
Difficulties With TDD & Refactoring (Or - Why Is This More Painful Than It Should Be?)
I wanted to teach myself to use the TDD approach and I had a project I had been wanting to work on for a while. It wasn't a large project so I thought it would be a good candidate for TDD. However, I ...
2
votes
3answers
121 views
Should I combine similar functions even though they are slightly different?
On an application I've been working on I have a function, connecting to a virtual machine, that can be performed two ways. The user can either select a machine from a list and click the "Connect" ...
1
vote
1answer
152 views
JSP Include: one large bean or bean for each include
I want to refactor a webapp that consists of very distorted JSPs and servlets. Because we can't switch to a web framework easily we have to keep JSPs and Servlets, and now we are in doubt how to ...
3
votes
1answer
123 views
Designing and refactoring of payment logic
Im currently working on an application that helps users to coordinate dinner clubs and all related accounting. (A dinner club is where people in a group, take turns to cook for the rest and then you ...
16
votes
7answers
1k views
To rewrite or slowly refactor old C++ project [duplicate]
Our team has recently inherited a relatively large project from another company (~250k lines). It was developed using C++Builder and we intend to port the Ui side to Qt. Most of the Ui code is ...
0
votes
2answers
332 views
Refactorable God v.s. too many classe [duplicate]
So I have this problem: in order to structure my code hierarchically, for every new tiny thing, I create a separate sub-folder, file, class ... and in it one 10-line function. It is an anti-pattern.
...
1
vote
4answers
173 views
Until what point should I refactor? [duplicate]
What do you think until what point should a programmer refactor the code?
Basically having
def method
do_something
end
Pieces of code would be handy, but they increase spaghetti code until the ...
2
votes
1answer
144 views
Why does the tool offer to change the code - just because it can?
Resharper (or is it Visual Studio - it's a yellow light bulb with a tiny red filament in it) offers to "invert if" on this code:
if (tItems >= 0)
{
return tItems;
}
SetTotalItemsAndTotalAmt();
...
-1
votes
1answer
190 views
Is there a tool that visually represents all the potential paths to a particular piece of code? [closed]
As an example of what I need and why I want it, I am trying to determine how a certain value (CurTotal) is getting set (wrongly). I've come up with these notes to myself to try to understand just what ...
2
votes
4answers
429 views
Get rid of long/Complex if..else statements using Chain of Responsibility?
I've an HttpHandler, which allows users to login to a system by passing in an encrypted code.
Inside the ProcessRequest it performs quite a few steps.
Retrieve the encrypted code from request ...
4
votes
3answers
456 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, ...
2
votes
1answer
89 views
What to name a new interface that is replacing an existing one?
We're redesigning our application's plugin interface, so we're using the Adapter pattern with our proof-of-concept design to show that the new interface will function without committing to using it in ...
8
votes
6answers
389 views
Is it better to have one method that takes a bool as a parameter or two methods with different names? [duplicate]
I'm writing a factory class for a Selenium Web Driver and I came across a choice that I couldn't figure out which is cleaner. Having two methods with the same parameter.
GetWebDriver(string browser)
...
2
votes
2answers
300 views
Refactored to a fancy global variable?
I am currently refactoring an application that i built in JavaScript.
The application uses a starting hour and a total working hour count in order to construct a timetable for daily, weekly and ...
3
votes
1answer
145 views
When to fracture a web application design into multiple products
Have you had this problem?
You are building a complex web application for a target market, and after a while you reach a point in complexity where you can't decide if you are building more than one ...
8
votes
3answers
287 views
I have to compromise: DRY, or Command-Query-Separation?
I was recently refactoring a method that was both a command and a query method.
After separating it into a one command method and one query method, I found that there are now multiple places in the ...
4
votes
2answers
139 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 ...
1
vote
1answer
201 views
Refactoring the shipping application code to use DDD factories
I was trying to find examples for using DDD factories and I came across the shipping application from Eric Evans' book.
However when I checked the BookingService the code to create a Cargo had this ...
1
vote
5answers
321 views
Is it sometimes reasonable to cut corners and expect to re-write software in a couple of years? [duplicate]
I work for an organization with one developer (me) and one DBA. When I started, the previous developer had developed applications that had bad architectural practices and it was getting and more time ...
2
votes
0answers
109 views
How to restructure Python frameworks [duplicate]
I just joined a group of five developers (non-professionals) working on a medium sized Python framework (> 50 modules, > 10.000 lines of code). The project has no documentation whatsoever and there ...
0
votes
3answers
471 views
What is good practice when inheriting static classes isn't possible/allowed
I am developing a project in C# and due to a design decision it is not possible to have a static class inherit another static class. But I have, in my opinion, a case where this would make sense.
I ...
2
votes
2answers
198 views
Should I split a Python class with many methods into multiple classes?
I have a class that will end up having more than ~30 methods. They all make sense to be part of the same class because they require access to the same data.
However, does it make any sense to split ...
2
votes
3answers
178 views
Refactor working code for reuse or duplicate?
I have always avoided duplicating code regardless of the circumstance. For example, if I have a working piece of functionality that needs to be re-used by different entities, I always refactor to ...
1
vote
1answer
70 views
A better approach to refactor code when doing A/B Testing
I'm asked to refactor my component code to support A/B Testing.
What is the better approach:
1) Pass a boolean value to the methods and check for that flag inside the method body?
method(flag ...
3
votes
2answers
75 views
How to refactor to cleaner version of maintaing states of the widget
Backstory
I inherited a bunch of code that I'd like to refactor. It is a UI application written in javascript.
Current state:
We have main application which consist of several UI components. And ...
0
votes
0answers
48 views
What would be the best way to refactor/rewrite a large base of plsql packages?
Let's suppose I have a large set of Oracle plsql packages and functions written in a period of 10+ years.
They are really hard to debug and maintain, and as the application grows we find it harder ...
0
votes
1answer
104 views
Refactoring classes with ref to themselves
How can I refactor this code?
class Node
{
public Node Parent { get; set; }
}
class AVLNode
{
public AVLNode Parent { get; set; }
}
I tried to use inheritance, but then I have to use type ...
1
vote
1answer
131 views
Reducing repetitive DI code
I have a method which constructs dependencies using Unity. Currently, all of the calls do pretty much the same thing: Registers 2 repository object and 2 'App Part' objects. My issue is, there's a lot ...
0
votes
2answers
154 views
Similar references to themselves in two classes
How can I make 1 class (base, generic or something else) from these two classes?
class A
{
A Link { get; set; }
}
class B
{
B Link { get; set; }
}
UPD: This is what I have now:
class BSTree
{
...
0
votes
2answers
229 views
How do I explain the value of refactoring to stakeholders? [duplicate]
How do I convince project managers, product owners, business analysts, clients and various other stakeholders that refactoring is a worthwhile and productive part of the development process?
As ...
4
votes
3answers
214 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 ...
3
votes
2answers
827 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 ...
1
vote
4answers
171 views
How Much Of A (Broken) Legacy Framework To Keep [duplicate]
I've inherited a hosted system (system "A") which can be used to manage products, inventory, and orders, and can send those products to various third-parties.
Quite simply, system "A" doesn't work. ...
56
votes
11answers
5k views
Is it a bad practice to modify code strictly for testing purposes
I have a debate with a programmer colleague about whether it is a good or bad practice to modify a working piece of code only to make it testable (via unit tests for example).
My opinion is that it ...
-3
votes
1answer
78 views
Refactoring methods with the same behavior [closed]
Imagine you have 2 methods :
GetConsolidation([...]);
GetReportOfConsolidation([...]);
These 2 methods use the same "behavior" (some local variables assigned with data) like :
var data = ...
0
votes
1answer
492 views
Introducing Fowler's Table Data Gateway to refactor poorly designed systems
I am developing an application, which currently has about 150,000 lines of code. The previous developer didn't really use any discipline when writing code. Application is in production but is ...