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

0
votes
1answer
43 views

What is the better way of getting different outputs for two very simmilar related workflows

I have a very concrete scenario but I think it would be quite frequent. I'm trying to come up with a solution that it's "better" by better meaning more scalable, reusable and not smelly. I'm working ...
3
votes
4answers
164 views

How to refactor my project to have less mutable objects? [duplicate]

There seems to be a trend towards immutable objects, and functional programming. I recently got aware about the benefits of immutability. However, I am not very familiar with this style of ...
0
votes
1answer
111 views

Writing code with language features yet to come in mind

In C#6, we will (most likely) have the nameof operator, a very useful operator for the ArgumentNullException pattern: public void M(T x) { if (x == null) { throw new ...
1
vote
2answers
532 views

How can i get around of infinite circle of technology change [duplicate]

I have been in web developement for 6 years. I am facing one big problem and i want to know how can i get rid of it. There are many personal projects like web application which i want o build. As an ...
2
votes
0answers
108 views

Unsafe redundancy refactoring in ReSharper 9.0?

Considering the following scenario: public class A { ... public virtual void Foo() { ... } ... } public class B : A { public void DoSomething() { ... base.Foo(); ... ...
-1
votes
1answer
79 views

How to improve and maintain technical integrity of a big codebase [duplicate]

Suppose there's a big project (a couple houndred KLOC) that has no explicit architecture - everyone can pretty much design stuff however they like overall poor design quality (code duplication, weak ...
4
votes
1answer
220 views

Derive from a base class but not include a condition in the base class's method

The current code looks like this: public class Details { Public void Populate() { WriteChapterDetails(); } public void WriteChapterDetails() { if ( ...
5
votes
2answers
451 views

When to fix something that is “wrong” but works fine

Short version: I wrote some code that is not done "the right way" because, when I wrote it, I didn't know how to do it. Now that I know how to do it "the right way", how do I decide how to fix it? ...
0
votes
1answer
43 views

refactor by inheritance or composition for large class that depend on common state [duplicate]

I have a huge class (>1000 lines), in which all methods depend on a small set of attributes in that class. I can think of 2 quick ways of refactoring. I keep it as a huge object, but split related ...
5
votes
1answer
113 views

How to use OO Design to Refactor a Library with Functions that are specific Product-aware

I have a class that acts as a library of functions for various products. To compute its data, the function currently needs to be aware of all product names. Depending on which product calls the ...
0
votes
2answers
83 views

Classic ASP to Java UI Conversion

My question is based on a business model of a financial services organization that currently is supporting applications that are a hybrid mix of Classic ASP and Java, with some JSP’s already in some ...
1
vote
4answers
187 views

What is the efficient way to eliminate duplication? Design patterns?

I have a helper class which has a method that perform some checks against a field in a model. I have two models, ModelA and ModelB, they have some similarities but not all. One of them is they both ...
1
vote
1answer
86 views

Lookup pattern as a way of passing global references

I am looking at some legacy code in java that uses the Service Locator pattern as a way of passing global references as opposed to passing them over and over again through method arguments and I am ...
51
votes
11answers
5k views

How do I avoid cascading refactorings?

I've got a project. In this project I wished to refactor it to add a feature, and I refactored the project to add the feature. The problem is that when I was done, it turned out that I needed to make ...
6
votes
5answers
2k views

How are financial organizations planning for the degradation of old programming languages such as COBOL? [closed]

I know that some financial organizations still use "dead" languages such as COBOL. I'm wondering what will happen in the future, when almost no one will program in those languages, and the ...
0
votes
1answer
147 views

Suggestions on refactoring a poorly written ASP.Net MVC web application [closed]

I have recently "inherited" a project written in ASP.Net MVC which has quite a few issues and I'm looking for suggestions on how to go about refactoring the code. The technical issues found so far ...
1
vote
2answers
103 views

Refactoring: reducing duplication without creating flags

I don't know how to refactor a piece of code that differs from other in the number of conditions checked on an if clause. Let me show you a real world example I'm facing right now. The only ...
4
votes
4answers
978 views

Refactoring: When to add a new class in the project?

When do you feel that you need a new class (maybe when you are developing or after development for refactoring purpose)? Maybe I can start from my existing variables and think how I can reorganize ...
1
vote
2answers
169 views

How do I tell my boss that their custom cms is terribly inefficient? [closed]

I started a new job about 2 months ago now with the job title of 'Programmer'. The web dev company I work for had made their own custom CMS and use it for all their sites. Conceptually, the idea is ...
3
votes
3answers
425 views

Choosing a random integer in a range such that it doesn't equal a particular number

Given an integer range and a number within that range, what's a reasonably robust and efficient way to randomly select a new number within the range such that it's not equal to the given number? ...
1
vote
1answer
132 views

Help Improve DB model/strategy, for use in refactoring SQL-ridden legacy code

Question: Which design pattern do I use to help me refactor legacy SQL code into separate classes? Goal Bring in concepts of data separation and database separation and also latest modern ...
2
votes
1answer
256 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
64 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
197 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
84 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
128 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
173 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 ...
2
votes
1answer
124 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
689 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 ...
1
vote
2answers
197 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 ...
0
votes
2answers
160 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 ...
3
votes
3answers
242 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 ...
2
votes
4answers
227 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
2answers
335 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 ...
36
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 ...
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 ...
0
votes
3answers
440 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 ...
0
votes
5answers
519 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
241 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 ...
1
vote
3answers
122 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, ...
0
votes
1answer
156 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 ...
2
votes
2answers
180 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 ...
7
votes
1answer
246 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 ...
0
votes
0answers
75 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
290 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 ...
2
votes
2answers
366 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 ...
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 ...
71
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 ...
1
vote
1answer
300 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 ...
10
votes
3answers
384 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 ...