refactoring

Making legacy straightforward win.forms application code more clear

I have legacy win.forms application written in pretty straightforward approach where forms communicate with DAL on UI events. For example there are textboxes: login/password, button - "Login" and a click-handler where business logic is implemented (DAL is asked to get user by id/password, if not null - than show next screen, if null - sh...

Ruby on Rails controller-view refactoring

Hello, In my app I am using the ym4r-gm plugin, which allows you to play with the Google Maps API... I put the map "setup" in the controller: @map = GMap.new("div_map") @map.control_init(:large_map => true, :map_type => true) @map.center_zoom_init([47.0, 26.0], 7) ... And only render @map in the view. So my first question is whether ...

Rename files in XCode

is it possible to rename/refactor a class file and have it rename the actual file on disk? if so, how can i do this? ...

BDD / TDD with JSpec - Removing code duplication

How do I refactor to remove the code duplication in this spec: describe 'TestPlugins' describe '.MovieScanner(document)' before_each MoviePage_loggedIn = fixture("movie_logged_in.html") // Get logged-in movie page MoviePage_notloggedIn = fixture("movie_not_logged_in.html") // Get no...

Is it better to comment out unneeded code or delete it?

Possible Duplicate: Do you leave historical code commented out in classes that you update? For web applications under maintenance, assuming you have source control, when you need to remove part of the UI and the associated code, do you delete the code and check in, or do you comment out the old code? Arguments in favor of del...

Drying out/refactoring flex/actionscript code

I have something like 10 components that have code that's very similar, except for the target that it's applied to and some other minor differences. For example, I return xml to component1 and component2 that differs in this way: component 1: event.result.names.name component 2: event.result.phones.phone I then bind these to a List, ...

Tools to detect duplicated code (Java)

I am in a project where previous programmers have been copy-pasting codes all over the place. These codes are actually identical (or very similar) and they could have been refactored into one. I have spent countless hours refactoring these codes manually but I think there must be a better way. Some are very trivial static methods that c...

How can I refactor our the type parameter from this code?

I want to write an extension method that tests if an attribute is applied on a method call, and I'd like to specify the method as a lambda expression. Currently, I have the following (working) approach, but I really don't like the way this code looks: // Signature of my extension method: public static bool HasAttribute<TAttribute, TDele...

Custom Inclusive TakeWhile(), is there a better way?

I've written a custom LINQ extension method that extends the TakeWhile() method to be inclusive, rather than exclusive when the predicate is false. public static IEnumerable<T> TakeWhile<T>(this IEnumerable<T> source, Func<T, bool> predicate, bool inclusive) { source.ThrowIfNull("source"); predica...

Liquibase, "Migration Failed: Java heap space" error when generateChangeLog with "data"

Hi all I am trying to create a baseline on one of my development database using liquibase, here's my environment - Database, -> Oralce 10g, with 500+ Tables with lots of configuration data, the oracle export dump file is about 70mb; - Java - Java 6 - Oracle JDBC Driver - ojdbc14.jar (downloaded from Oracle web site) - Command line execu...

Sanitize pasted text from MS-Word

Here's my wild and whacky psuedo-code. Anyone know how to make this real? Background: This dynamic content comes from a ckeditor. And a lot of folks paste Microsoft Word content in it. No worries, if I just call the attribute untouched it loads pretty. But the catch is that I want it to be just 125 characters abbreviated. When I add tr...

How to Refactor a fat interface?

Lets say i have the following set of interfaces.... public interface IStart { void M1(); bool IsWorking { get; } } public interface IStartStop : IStart { void M2(); event EventHandler DoM1; event EventHandler DoM2; } public inter...

Refactor that code ... Controls.Find method

OK, I have a code (see below): void M1() { for (int i = 1; i < 10; i++) { Control[] carr = this.Controls.Find("Number" + (i - 1).ToString() + "CheckBox", true); if ((carr != null) && (carr.Leng...

WPF/MVVM: Refactoring Code-Behind to make it ready for MVVM binding

Hello, I have this code in my code-behind file of my View: private string GetSelectedSchoolclassCode() { return ((SchoolclassCode)cboSchooclassCodeList.SelectedItem).SchoolclassCodeName; } private void dgTimeTable_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var columnNumber = dg...

Rails: Facebox link if condition is satisfied

I want to display a facebox link when I click on a element when a particular condition is satisfied. I do not want the user to click if the condition is not satisfied. I am doing something like this to achieve it which is pretty ugly <% if x == 5 %> <a id="something" href="http://www.some_weird_link.com" rel="facebox"> <% end %> <...

return statements when doing Extract Method

Let's say you have a very long method, like this: int monster() { int rc = 0; // some statements ... if (dragonSlayer.on_vacation()) { cout << "We are screwed!\n"; if (callTheKing() == true) return 1; else return 2; } else { cout << "We are saved!\n"; slay...

Is there any good code analysis/refactoring tools for T-SQL besides RedGate?

I've used RedGate in the past, but the feature-to-price ratio really sucks. At $369 for one-year it is far too expensive when compated to much richer applications like CodeRush and Resharper. ...

Algorithm to determine proper divisors

Hi all, I am interested in finding the numbers that exhibit the property of having the sum of their proper divisors equal to the number. The first example is 6, where the proper divisors are 1 + 2 + 3 = 6. I wrote the following code in R, but I feel it is pretty inefficient and can be improved upon significantly. propDivisor <- func...

What is the best way to explain refactoring to non-technical people?

We have a project on at the moment where we are refactoring an application that works fine for the moment but under the hood is beyond help. We need to rewrite it so that changes and maintenance can be achievable. The problem is that after the project is done, the application will look and feel cosmetically and functionally the same. ...

Refactoring some code with 'instanceof' to overloaded method solution in Java

I have this piece of code from GWT in Action: public void processOperator(final AbstractOperator op) { System.out.println("Wordt deze ooit aangeroepen?"); if (op instanceof BinaryOperator) { if ((data.getLastOperator() == null) || (data.isLastOpEquals())) { data.setBuffer(Double.parseDouble(da...