3
votes
3answers
197 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 ...
0
votes
2answers
178 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 ...
6
votes
1answer
227 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 ...
4
votes
2answers
150 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
4answers
229 views

Should refactoring be the exception or the rule? [closed]

I had a discussion with a co-worker yesterday about design philosophy. The other coder is more experienced then me, and I fully admit that he is likely much better at properly automating his testing, ...
0
votes
0answers
62 views

On the process of replacing an internal framework by a public one [duplicate]

I am working on several applications which depends on a framework which was developed by a prior engineer in the company. The framework was mainly developed and maintained in the early 2000s, and ...
1
vote
2answers
141 views

Code Duplication in Multi-Module Project

I've about seven modules arranged like so: Service Processing Common Account Email Scheduling I try to make it my policy to restrict code to the module that actually uses it. Code that is shared ...
5
votes
5answers
626 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 ...
-1
votes
1answer
108 views

What is meant by a step-by-step refactoring plan describing implementation of design [closed]

What is meant by a step-by-step refactoring plan describing how to implement a certain design? As little as I know about refactoring it regards improving a (UML) design model and has nothing to ...
2
votes
1answer
197 views

Designing and refactoring of payment logic [closed]

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 ...
2
votes
2answers
339 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
160 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 ...
1
vote
5answers
379 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 ...
3
votes
2answers
79 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 ...
4
votes
3answers
219 views

Using the mouse as a multi-tool creates heavy conditional logic for executing commands, how do I change this?

The feature is in many different types of editing programs where a mouse click may have completely different commands to execute (using the Command Pattern) Currently I have an overarching ...
4
votes
7answers
608 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 ...
5
votes
2answers
232 views

How to do unit tests on a method that takes the elapsed time into account?

I'm currently in the middle of refactoring an important method in a legacy-system. There were almost zero test until I've started working on it, and I've added quite a lot to ensure the correct work ...
5
votes
3answers
316 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 ...
3
votes
2answers
261 views

Overcoming circular reference

I am working on an asp.net MVC web application which contains several projects. One is BusinessObjects, which contains business logic / processes. Another is EmailGeneration which is used to send ...
4
votes
3answers
285 views

How to refactor “nested” view classes to avoid deep method calls?

Lets say I'm displaying a bunch of data (model) using a View class for rendering. However, a lot of the data has sub-data (models) complicated enough to require separate rendering classes. In my ...
5
votes
1answer
362 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 ...
8
votes
4answers
375 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
178 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
877 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, ...
9
votes
4answers
774 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": ...
8
votes
6answers
877 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 ...
3
votes
2answers
94 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
1answer
113 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 ...
3
votes
1answer
709 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. ...
8
votes
9answers
5k 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"); ...
2
votes
4answers
202 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 ...
5
votes
3answers
195 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 ...
9
votes
1answer
1k views

How to refactor a Python “god class”?

Problem I’m working on a Python project whose main class is a bit “God Object”. There are so friggin’ many attributes and methods! I want to refactor the class. So Far… For the first step, I ...
6
votes
1answer
388 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 ...
2
votes
3answers
352 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 ...
9
votes
8answers
444 views

Refactoring or upgrading databases to handle new features

Several responses to a database schema question, suggested an additional table to normalize a database for a feature that is not part of the current requirements (A UserDepartment table to allow for a ...
14
votes
9answers
1k views

We're not a software company. Is a complete re-write still a bad idea? [duplicate]

I understand the reasoning behind Joel Spolsky's article "Things You Should Never Do, Part I", but I always see it referenced in regards in situations where the end goal is the production of software. ...
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, ...
18
votes
15answers
1k views

Refactoring: Isn't it just a fancy word for clean up your code?

Before Martin Fowler's book "Refactoring: Improving the Design of Existing Code" came out, we used to call major changes to code "rearchitecture" and minor changes "cleanup". IMO, refactoring ...
10
votes
2answers
394 views

How to organize repetitive code?

My team creates a lot of one-off web forms. Most of these forms just send an e-mail, and a few do a simple database write. Right now, each form lives in its own separate solution in Visual Studio ...
2
votes
5answers
304 views

how to evaluate own project

I am working on a open source project in pure C, that I have started some time ago, but only recently found time to add some features. I can clearly some weaknesses of my old design, so I am trying to ...
11
votes
4answers
407 views

Code duplication with no obvious abstraction

Have you ever encountered a case of code duplication where, upon looking at the lines of code, you couldn't fit a thematic abstraction to it that faithfully describes its role in the logic? And what ...