refactoring

A type with "Manager" in the name - candidate for refactoring?

I found a thesis on forums: If you have a type with "Manager" in the name, it's a candidate for refactoring. One answer: I know it's considered a code "smell" So... Why? Is this thesis correct? There are many managers out there. For example, Ogre3d uses them a lot, and this engine really has a clean architecture. ...

Delphi: How to move a class out of a unit;avoid circular references

Question: i want to split two classes out to their own file, while avoiding circular references. i have a unit with some classes (and some enumerations and constants). Anyone will recognize Click and Clack the tappet brothers: unit Cartalk; interface type TSolution = (solTransmission, solBrakes, solGremlins); TTappetBrothe...

How do I refactor closing a stream in Java?

Due to my company's policy of using Eclipse and using Eclipse's code-autofix, the following code pattern appears excessively in the codebase: InputStream is = null; try { is = url.openConnection().getInputStream(); // ..... } catch (IOException e) { // handle error } finally { if (is != null) { try { ...

When is it time to refactor code?

On on hand: 1. You never get time to do it. 2. "Context switching" is mentally expensive (difficult to leave what you're doing in the middle of it). 3. It usually isn't an easy task. 4. There's always the fear you'll break something that's now working. On the other: 1. Using that code is error-prone. 2. Over time you might realize that ...

Silverlight Custom Gird with Fixed Header and Column, required refactoring

Hi All, I’m trying to build the custom grid with fixed Header and Column in Silverlight. I don’t know whether SL has built in functionality to build this or not because I’m very new to SL. Please take a look the following codes. I don’t think that this is the right way to build this. If you don’t mind, please refactor my codes and pleas...

Cleanly duplicate an instance of a baseclass or subclass in C++?

In the trivial example inheritance hierarchy: class Food { virtual ~Food(); }; class Fruit : public Food { virtual ~Fruit(); }; class Apple: public Fruit { virtual ~Apple(); } class Vegetable: public Food { virtual ~Vegetable(); } I wish to create a method that can clone an object from its subclass or baseclass inst...

Is there a refactoring tool for SQL Server Database

Hi I would like to know if does anybody know a freeware refactoring tool, in which I could rename some table columns and get those names also renamed in my stored procedures. Does it exist? ...

How can I refactor a large block of if statements in Java?

I recently profiled some code using JVisualVM, and found that one particular method was taking up a lot of execution time, both from being called often and from having a slow execution time. The method is made up of a large block of if statements, like so: (in the actual method there are about 30 of these) EcState c = candidate; ...

Workflow for renaming a class when using Visual Studio with Perforce

(I am new to perforce and am trying to avoid getting myself into problems, I have hit problems doing this with other source code control systems) When I rename I class I need to Change the class name it’s self Get Visual Studio to Refactor all the code that uses the class Rename the file in the Visual Studio project Rename the file in...

Does this Rails 3 Controller method make me look fat?

This is a new application, and I have an index method on a Search controller. This also serves as the home page for the application, and I'm trying to decide if I am headed down the wrong path from a design pattern perspective. The method is already 35 lines long. Here is what the method does: 3 lines of setting variables to determine...

Better way of refactoring this ?

I have the following classes: public abstract class BaseClass { private readonly double cachedValue; public BaseClass() { cachedValue = ComputeValue(); } protected abstract double ComputeValue() } public class ClassA : BaseClass { protected override double ComputeValue() { ... } ...

What Are The Motivations And Benefits Of Refactoring?

Why do we do refactoring? What are the benefits of refactoring? What problems can be avoided by performing refactoring the code of a software tool? ...

Is using “feature branches” compatible with refactoring?

“feature branches” is when each feature is developed in its own branch and only merged into the main line when it has been tested and is ready to ship. This allows the product owner to choose the features that go into a given shipment and to “park” feature that are part written if more important work comes in (e.g. a customer phones up...

Refactoring JavaScript and PHP code [Job Interview]

Hi, recently I had a job interview. I had two tasks: 1) to refactor a JavaScript code // The library 'jsUtil' has a public function that compares 2 arrays, returning true if // they're the same. Refactor it so it's more robust, performs better and is easier to maintain. /** @name jsUtil.arraysSame @description Compares 2 arrays, re...

Refactor the namespaces in a SOLUTION

I am changing the Default Namespace for my projects in the solution. I can use Resharper for example to adjust the namespaces for me in ONE project. but I am looking for some tool that can adjust the namespaces in the whole SOLUTION. I am using VS2008 pro. is there a refacotring tool that can adjust the namespaces in the all projects of...

Name for factoring out repeated code into separate function

I'm trying to find research/advice on a particular code refactoring pattern, but I'm finding it hard to locate, since I'm not sure whether there's a good name for it. It's very similar to factoring out repeated code, except the code wasn't repeated in the first place: it was just stashed away in a conditional branch of a larger function...

good refactoring or bad?

Given the following code: status = row[COL_STATUS] if status == "idle": row[COL_EDITABLE] = True row[COL_FONTSTYLE] = pango.STYLE_NORMAL row[COL_WEIGHT] = pango.WEIGHT_NORMAL elif status == "DCed": row[COL_EDITABLE] = True row[COL_FONTSTYLE] = pango.STYLE_ITALIC row[COL_WEIGHT...

Example of Delphi refactoring involving data aware controls and datamodules with direct access to db tables

I am trying to define the best way to refactor the project I am working on. Due to lack of good design almost all project is made up of: 1) forms containing business logic 2) huge datamodules (1 per form + some extra ones) 3) some units that contain common code (libraries) There is no OOP (except for some small areas), code reuse it...

I have a method in program.cs that I want to transfer to its own class

I'm new. I'm trying to take the pigTalk() and transfer it into its own class Thanks for any help using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace FunctionTest { public class Program { public static void pigTalk(string sentence) { try { ...

Refactor: Multiple params in find query

Need some help refactoring this if/else block that builds the conditions for a find query. if params[:status] && params[:carrier] conditions = ["actual_delivery IS NOT NULL AND actual_delivery > scheduled_delivery AND status_id = ? AND carrier_id = ?", status.id, carrier.id] elsif params[:status] conditions = ["actual_delivery IS NO...