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
vote
1answer
412 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 ...
1
vote
1answer
199 views

Convert procedural code to object oriented

I have a PHP application (a web service). It consists of files grouped in directories by theme like :      /customer         /search.php with this example content : Auth::authenticate($options); ...
1
vote
0answers
58 views

Need to refactor file downloader and post processing utility [duplicate]

Not sure whether this is the right forum to ask this but here goes. Using this solution - http://stackoverflow.com/questions/26571351/replacing-if-else-logic-with-state-strategy-pattern I was able to ...
2
votes
3answers
157 views

Refactoring web pages with user controls

Is it good design to use many user controls to help refactor a web application? In my case, it's a VB.NET Webforms ASP.NET website. All our pages are organized into sections that, while related and ...
0
votes
0answers
45 views

API for accessing CTS and DSR signals of serial port

I'm trying to improve another abstraction of the serial port. The project involved often needs to check one of the single control signals CTS and DSR. This is currently done by a call to ...
0
votes
2answers
119 views

Should I worry about performance, even if there is no loss of convenience? [duplicate]

Assume an application that shows a data table. The data is loaded from a database when the program is initialized. Each value in the table is represented by an input field, where each keypress in one ...
2
votes
4answers
165 views

What can be done when you are the only person to care about consistency? [closed]

After reading this question I may have a partial answer to the issue at hand, but I'd like to explore the issue further. I seem to be the only person on my team (a team of 6 people working on an ...
7
votes
6answers
340 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. ...
1
vote
2answers
120 views

Microchip XC8: How to pack code against an upper limit?

I have a project for a PIC16F1454 that needs some custom linking. Basically, I've separated my code into two parts that can be downloaded separately in the field and thus update (almost) all of the ...
2
votes
1answer
122 views

RefactorException: Good idea or bad idea?

When I'm doing large scale refactors I'm often commenting out the contents of methods and using NotImplementedExceptions for stuff that I still need to refactor. Problem is that this is interfering ...
17
votes
6answers
518 views

Is randomly refactoring code allowed in scrum

Background My team uses scrum I have currently no task assigned There are no more pending task in the backlog Today is Labor Day for my client. Not having many things to do today I wanted to start ...
0
votes
2answers
149 views

Designing Nested List<Class> Property in a Class

I'm currently in the class modeling phase of my project. Real life Scenario: Let's say I have a Project that is composed of Main Components and each Main Component is composed of Sub Components and ...
0
votes
3answers
420 views

Eliminate duplicate code in nested IFs without creating a function [duplicate]

Let's say we have two ifs that depend on each other: if var exists { if var is array { //Do stuff with var } else { //Resolve the problem } } else { //Resolve the ...
3
votes
3answers
219 views

How would you rewrite/refactor this ? [duplicate]

Old application that is used by 50-60.000 paying customers. Company is several hundred people big. Application has a lot of business critical code (30% of all code) written in classic asp. Application ...
19
votes
12answers
567 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 ...
2
votes
4answers
214 views

How to refactor a myriad of similar classes

I'm faced with similar classes A1, A2, ..., A100. Believe it or not but yeah, there are roughly hundred classes that almost look the same. None of these classes are unit tested (of course ;-) ). Each ...
0
votes
1answer
113 views

Refactoring a Single Rails Model with large methods & long join queries trying to do everything

I have a working Ruby on Rails Model that I suspect is inefficient, hard to maintain, and full of unnecessary SQL join queries. I want to optimize and refactor this Model (Quiz.rb) to comply with ...
35
votes
7answers
5k views

Why do people nowadays use factory classes so often? [closed]

I've seen the history of several С#/Java class library projects on GitHub and CodePlex, and it seems like a trend. Why do people nowadays use factory classes so often for almost everything? I.e. We ...
0
votes
2answers
240 views

How often do you refactor or restructure your code in long term projects? [duplicate]

As developers we are always eager to learn new things and better ourselves at what we do. You've all had moments when you look at your old code and get that feeling: "WTH, I can't believe I used ...
26
votes
9answers
2k views

Why are deadlines always so short? [duplicate]

I'm a junior developer in a small company (in a team of 2 developers). Everytime we are asked to implement a new feature: the deadline is set so that we just have time to do the development: there ...
8
votes
9answers
6k 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"); ...
0
votes
5answers
485 views

Fixing bugs in other peoples code [duplicate]

I'm working with another programmer and we are always having issues with refactoring or changing each others code. Recently I had to fix a bug, but I pushed the changes before notifying him. He was ...
1
vote
1answer
238 views

I made improvements to free code I found online and notified the author. Was this the right thing to do? [closed]

I recently used a library from http://www.braemoor.co.uk/software/index.shtml (the EU VAT No validation library at http://www.braemoor.co.uk/software/vat.shtml) in a project at work. It mentions as ...
2
votes
3answers
356 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 ...
1
vote
3answers
121 views

Can I refactor “safely” without specs? [duplicate]

I have inherited a legacy web application many years which: Does not make use of Object Oriented principles, even though the language would permit it Has no unit tests, nor any sort of test suite, ...
19
votes
10answers
1k 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? ...
8
votes
4answers
859 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 ...
4
votes
3answers
571 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 ...
7
votes
1answer
235 views

Suggested method for extracting a standalone C library from an existing R package?

My group has been developing an R package to simulate plant growth (see GitHub repository). The R package uses .Call to interface with C. We have decided that it would be worthwhile to create a ...
2
votes
2answers
140 views

When does extracting methods from code stop to make sense? [duplicate]

I am currently studying the refactoring methods defined by Marting Fowler (http://refactoring.com/catalog/). He states a tip for replacing chunks of code by a single method that does that job. So ...
0
votes
0answers
53 views

Rewriting/decoupling important service of the Django website in Erlang

We have application written entirely in Django, which consist of three separate components. Admin, Service for generating invoices + API and UI for users. Problem is, that they are very tightly ...
1
vote
2answers
247 views

Retrying a statement or call in a catch block - code smell or anti-pattern?

I'm wondering how better to perform this operation for a large amount of files. The bit I'd like some thoughts on whether this copy/paste is acceptable enough of a tradeoff. try to write a file if ...
7
votes
6answers
1k 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 ...
41
votes
12answers
3k views

Reconciling the Boy Scout Rule and Opportunistic Refactoring with code reviews

I am a great believer in the Boy Scout Rule: Always check a module in cleaner than when you checked it out." No matter who the original author was, what if we always made some effort, no ...
2
votes
2answers
314 views

Reduce number of if statements through design pattern

I had a loop through object Process, each process instance can be of a different type, derived from Process base class (e.g.: Process1, Process2,...). Each derived type of Process has different ...
70
votes
6answers
5k views

Fixing a spelling mistake in a method name

One of the methods that I commonly use in our codebase is misspelled (and it predated me). This really irritates me not simply because it is mispelled but more importantly it makes me ALWAYS get the ...
53
votes
17answers
2k 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 ...
10
votes
3answers
353 views

Continuing to code on large projects

I am a hobbyist programmer, and I've started many medium - sized projects to work on just by myself. These include games, a raytracer, physics simulations etc. By the time these projects get to a ...
1
vote
1answer
238 views

Advice on refactoring PHP Project

I have a small SAS ERP that was written some years ago using PHP. At that time, it didn't use any framework, but the code isn't a mess. Nowadays, the project grows and I’m now working with 3 more ...
62
votes
10answers
4k views

Does it make sense to write tests for legacy code when there is no time for a complete refactoring?

I usually try to follow the advice of the book Working Effectively with Legacy Code. I break dependencies, move parts of the code to @VisibleForTesting public static methods and to new classes to make ...
5
votes
2answers
241 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, ...
0
votes
2answers
150 views

Follow the deadlines vs Do it right [duplicate]

I have been given a huge task of migrating few functionalities from jQuery to AngularJS. I have been pretty good at Angular by now. But I want to dive deep and create futuristic, sound architecture. ...
12
votes
7answers
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. ...
1
vote
3answers
246 views

Use unnamed object to invoke method or not?

If I have a class with only only public method. When I use this class, is it good to use unnamed object to invoke its method? normal: TaxFileParser tax_parser(tax_file_name); auto content = ...
45
votes
6answers
2k views

Refactoring into lots of methods - is this considered clean or not? [duplicate]

So, I watched as my colleague complained a bit about a project he has inherited from someone who is, shall we say, not very experienced as a programmer (intern left to his own devices on a project). ...
8
votes
1answer
411 views

Refactoring a 1500 LOC method that only builds the graphical UI [closed]

I'm currently scratching my head over how to refactor a method that basically only builds the UI. The method is more than 1500 lines of code (LOC) long - and counting. It has grown, there was no plan ...
0
votes
1answer
227 views

Can JSP Expression Language provide type safety like scriptlets in Eclipse IDE?

Almost everywhere you can read that you should use EL instead of scriptles in JSP. And I agree that you should not use any JAVA code in JSP except for calling getter methods on model objects. This is ...
1
vote
1answer
142 views

How to manage a winforms application installed in many PCs connected to a single sql database?

I have a winforms application that connects to a single sql server 2012 database and is executed in many PCs of a company. I'm having several problems with some transactions inside the application, ...
4
votes
2answers
166 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 ...
2
votes
5answers
459 views

DRY code, DRY tests?

At some point I had to create some class "Class1" and that class needs a method "method". So I have the following: Class1MethodTest: A total of N tests that check the behavior of Class1.method Class1 ...