refactoring

Form_Load() 'event' or Override OnLoad()

I would like someone to try and explain the difference between these. More specifically, example usage scenario's. I am refactoring some Windows Form code and a Form has some code in the Form_Load() event and also in a protected override void OnLoad() event that calls base.OnLoad(e); Now I traced it and the Override fires first and ...

Can Resharper learn to recognize linked files when refactoring?

Is it possible to make resharper include linked files when refactoring? Consider a solution setup with the following projects: Backend Services //Depends on 'Backend' and 'Services.Shared' Services.Shared Services.Shared.Silverlight //This project links all sourcecode in 'Services.Shared' Frontend //Depends on 'Services.Shared' through...

What are some useful emacs functions for refactoring ?

For now I've stuck with multi-occur-in-matching-buffers and rgrep, which, while powerful, is still pretty basic I guess. Eventhough I realize anything more involved than matching a regexp and renaming will need to integrate with CEDET's semantic bovinator, I feel like there is still room for improvement here. Built-in functions, packag...

How to refactor legacy code effectively and efficiently?

Possible Duplicates: What should I keep in mind in order to refactor huge code base? When is it good (if ever) to scrap production code and start over? I am currently working with some legacy source code files. They have quite a few problems because they were written by a database expert who does not know much about Java. Fo...

How to Replace (and not just move) Conditional Logic with Strategy?

In Refactoring to Patterns the author replaces the conditional logic by having the client use Loan factory methods where each uses the appropriate Strategy for the given arguments. However, I feel like it has passed the conditional logic code to the client, which must choose based on the arguments which Loan factory method to call. Isn't...

Refactor before or after ship?

In a world where most ship dates are dictated by business needs, programmers usually ship code that works. Often, structure and efficiency of code being shipped become moot when you know code works. Unless production quality is specified (api to an algorithm for example), for code running into few hundred lines, shippable code equals cod...

Reasons for refactoring tools for C/C++ to be so limited

What is the problem that no industrial level refactoring tool for C/C++ have been created, I only need a tool that "just works"? What I mean by "industrial level" is a quality provided by JetBrains products (IntelliJ, ReSharper), or above. Any available solutions (including Visual Assist from Tomato Software or Eclipse CDT) are not matu...

Tutorial for speeding up SQL queries?

Is there a good tutorial out there how to speed up/refactor SQL Queries? I googled a bit, but did not find anything useful. Thanks :-) ...

Defining a callback function for a given value

In Java, is it possible to associate some object (i.e. a String) with a function to be called ? I have two similar menus and both have a onClickListener with some code like this: if (item.id==0) { doSomeFunction(argument); } else if (item.id==1) { doSomeOtherFunction(); } else if (item.id==2) { doStuff(arg2); } else { } I would j...

proper C refactoring

I have the following files: a.h, a.c, b1.c, b2.c and in both b1 and b2 I have some macro definitions which are identical. Is it ok if I move them in a.h or is it more common to leave them in the file where they are being used ? Which way is the proper way to do it in C ? ...

Can CodeRush with Refactor Pro and CodeItRight co-exist?

Does anyone know if these two products can coexist? Will these tools get in eachothers way? ...

Am I breaking the "Law of Demeter"?

I just recently became aware of the Law of Demeter. Like a lot of things, I realized that it was something that I was already doing but did not have a name for. There are a few places though that I seem to violate it. For example... I might have an Address object: public class Address : IAddress { public string StreetAddress { ge...

Effect of refactoring on program speed

As a programmer I use to follow TDD, beginning by writing a simple version of my code then heavily refactoring it. When refactoring I usually just listen to my code. I search for bad smells and then refactor the code to remove smells. Typically I will introduce new methods to avoid repeating code, move class members around to put them ne...

Javascript: Is there a benefit to using a return statement that returns nothing?

I'm refactoring a large javascript document that I picked up from an open source project. A number of functions use inconsistent return statements. Here's a simple example of what I mean: var func = function(param) { if (!param) { return; } // do stuff return true; } Sometimes the functions return boolean, so...

How to remove CSS spaghetti in legacy web app?

After working on several large web applications, and seeing gigantic style sheets with no clear structure, I'd really love to know if people have found ways to keep their css clean for large and complicated web apps. How do you move from a legacy, mess of css to cleaned up, nicely cascading, DRY stylesheets? The app I'm currently work...

Is there a more modern, OO version of "Let's Build a Compiler"?

Is there a more modern, maybe object-oriented, equivalent to Jack Crenshaw's "Let's Build a Compiler" series? A while back I stumbled across "Let's Build a Compiler" and could just not resist writing some code. I wrote a recursive-descent C compiler in C# that output .NET CIL. "Write once, leak everywhere" was my slogan. Too bad I di...

Shortening this IF statement

I don't like wide code, especially when it forces me to scroll. So having written this: If _item.SubItems(pd.perioddate).Text = "N/A" Or _item.SubItems(pd.perioddate).Text = String.Empty Then dtpDeadlineforAP.Checked = False End If Is there a decent way to thin it down, make it more elegant? ...

Rails Paperclip 'class methods' and validations refactor ?

Hi, I've been breaking the DRY principle a bit in a project built with Paperclip for media storage. I've added assets to certain models, such as AlbumPhotoFile, AlbumSoundFile and so on, using the following code : # Asset is a regular < ActiveRecord::Base class class AlbumPhotoFile < Asset has_attached_file :pic, :url => "foo", :pat...

Refactor $(document).ready(), currently have 2 instances.

Hi all, I've got following JavaScript functions but want to refactor the $(document).ready() as I've got 2 instance of it. How can I achieve this? FlashMessenger = { init: function() { setTimeout(function() { $(".flash").fadeOut("slow", function () { $(".flash").remove(); }); ...

Is there any safe refactoring tool for .net (or at least c#)?

Hello, I recently read Michael C. Feathers' book Working effectively with legacy code and came across the point where he mentioned a way to test the safety of automatic refactoring tools. My question is: Are there any safe refactoring tools for the .net platform?; that means tools which only allow real refactorings and e.g. don't allow ...