refactoring

All Strings to resource

Hi I'm Looking For a tool that help me to extract all strings of my code files to Resource File. I Used Coderush and Microsoft add on(resourcerefactoring.codeplex.com) for working with Resource files. but i had to extract strings to resources one by one. Is there any better option? ...

Log statements prevent refactoring: how to help this?

Hello all, I have some relatively large legacy method that I would like to refactor. It fits "Bulleted method" type as specified in Michael Feathers' "Working Effectively With Legacy Code" and thus it could be split in several sequential methods in rather straight-forward way . But each of its sequential steps outputs some log message a...

django: how to evaluate a project for refactoring

Has anyone of you done evaluation of a django project and how to improve/refactor it's code base? A pet project in company I work at is becoming more widely used and it would be good to improve its quality before further development. Are there any techniques or methodologies of analyzing django projects before we start putting more and m...

Visual studio refactoring a property of a viewmodel does not reflect in the View?

I have a simple ViewModel class like public class TestViewModel { public String Information { get; set; } } My View inherits from it and I got Intellisense kicking in. So far so good. I have written these for tests in the View: <%= Html.Encode(Model.Information) %> -- <%= Html.Label("Information") %> -- <%= Html.LabelFor(m => m....

How can I extract all classes into separate file?

I'm using the Resharper trial and VS2008. Is it possible to extract all classes from one file into a separate file? I'm able to do this using Resharper but it only seems to work for individual classes. This is to be used on a file that was auto-generated that is 65,000 lines long. ...

How to refactor this Ruby code aiming to change an hash's symbols into strings?

I just wrote this piece of code but I'm not quite happy about it. data = {} options.each{ |k,v| data.merge!({k.to_s => v}) } Basically I have: {:a => "something", :b => "something else", :c => "blah"} ... and I want ... {"a" => "something", "b" => "something else", "c" => "blah"} ... in order to send it to a gem that do not hand...

Project Euler: Problem 1 (Possible refactorings and run time optimizations)

I have been hearing a lot about Project Euler so I thought I solve one of the problems in C#. The problem as stated on the website is as follows: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 be...

Please help transform Tsql "implicit joins" into explicit ones.

Sorry, I am pretty much an SQL noob. This has to work in MSFT SQL, Oracle as well as Sybase. In the following snippet I need to change an inner join between IJ and KL on IJ.PO_id = KL.PO_id into a left join also on IJ.PO_id = KL.PO_id. So, I believe I have to re-factor this. Well, implicit joins are not the most readable, at least in my ...

Need suggestions regarding Interface refactoring

Hello everyone! I have inherited a project that has an awkwardly big interface declared (lets call it IDataProvider). There are methods for all aspects of the application bunched up inside the file. Not that it's a huge problem but i'd rather have them split into smaller files with descriptive name. To refactor the interface and break i...

Can eclipse convert/refactor a method to a class?

This seems like it should be fairly straight-forward, but I can't see anything obvious. What I basically want to do it to point at a method and refactor->extract class. This would take the method in question to a new class with that method as top level public API. The refactoring would also drag any required methods and variables alon...

How to refactor this code

I am currently refactoring some old code. I am looking for directions on the best design pattern to use here. I am thinking of the factory pattern but I am not sure if that's the best way to go or not. So here is a brief outline of the pseudocode. Class Foo has the core business logic in it. Class Foo{ private List<Things> stuff;...

What is the best way to handle the restriction of an API?

Our core domain so far has an abstraction called PersonName with methods for firstName, lastName, middleInitial etc. As we are expanding the domain to Spain, we figured that they only talk in terms of name, firstSurname and secondSurname i.e. middleInitial etc have no significance to them. The PersonName interface is currently being use...

Do very long methods always need refactoring?

I face a situation where we have many very long methods, 1000 lines or more. To give you some more detail, we have a list of incoming high level commands, and each generates results in a longer (sometime huge) list of lower level commands. There's a factory creating an instance of a class for each incoming command. Each class has a proc...

Design pattern to refactor switch statement

I have something like the following in the header class MsgBase { public: unsigned int getMsgType() const { return type_; } ... private: enum Types { MSG_DERIVED_1, MSG_DERIVED_2, ... MSG_DERIVED_N }; unsigned int type_; ... }; class MsgDerived1 : public MsgBase { ... }; class MsgDerived2 : public MsgBase { ... ...

Java 1.4 to Java 1.5 - Rewrite code and avoid the @SupressWarnings

Hello everybody, I have an old personal project written in Java 1.4 that I am porting to 1.5 (in which I am a still newbie) for version 2. Besides adding new features to it and refactoring code, I am also migrating to generic collections, annotations etc. There is a particular piece of code that I don't know how to change to 1.5 and do...

How to refactor this routine to avoid the use of recursion?

So I was writing a mergesort in C# as an exercise and although it worked, looking back at the code, there was room for improvement. Basically, the second part of the algorithm requires a routine to merge two sorted lists. Here is my way too long implementation that could use some refactoring: private static List<int> MergeSortedList...

C# Refactoring: How would you refactor 2 methods that do the same except that they use a different Interface

Having 2 different interfaces is a must. How would you refactor this? Should I refactor this code at all? private void CreateInstanceForProviderA() { a = FactorySingleton.Instance.CreateInstanceA("A"); if (a == null) { ShowProviderNotInstanciatedMessage(); return; } a.Owner = Handle.ToInt32(); ...

NetBeans refactor class: java.lang.NoClassDefFoundError

I just came across an error when using NetBeans, and I wanted to post my findings (possible this is old news). Perhaps this will save some people the headache of debugging a similar problem that I just encountered. I don't think I'm abusing anything here... stack overflow's SEO is pretty good :) I refactored a class in NetBeans (JavaFX ...

Dictionary of Primes

I was trying to create this helper function in C# that returns the first n prime numbers. I decided to store the numbers in a dictionary in the <int,bool> format. The key is the number in question and the bool represents whether the int is a prime or not. There are a ton of resources out there calculating/generating the prime numbers(SO ...

Refactoring Form.ShowDialog() code to MVP

Hi All, I have a WinForm and few properties that are set on it. for example : Name,Address are accepted on the Form. (many more properties in actual example) The current implementation is somewhat similar to frmName frmView = new frmName (); //frmName is WINFORM frmView.Name= "ABC"; //any valid string or read this from file frmV...