refactoring

Best way to get rid of hungarian notation?

Let's say you've inherited a C# codebase that uses one class with 200 static methods to provide core functionality (such as database lookups). Of the many nightmares in that class, there's copious use of Hungarian notation (the bad kind). Would you refactor the variable names to remove the Hungarian notation, or would you leave them alo...

Converting C source to C++

How would you go about converting a reasonably large (>300K), fairly mature C codebase to C++? The kind of C I have in mind is split into files roughly corresponding to modules (i.e. less granular than a typical OO class-based decomposition), using internal linkage in lieu private functions and data, and external linkage for public func...

Refactoring features in Visual Studio 2005 for VB

Hi, Does anybody know a good and free add-in for Visual Studio 2005 to get refactoring features in VB? Thanks in advance /Enrico ...

How do you handle the tension between refactoring and the need for merging?

Hi, Our policy when delivering a new version is to create a branch in our VCS and handle it to our QA team. When the latter gives the green light, we tag and release our product. The branch is kept to receive (only) bug fixes so that we can create technical releases. Those bug fixes are subsequently merged on the trunk. During this t...

What tool to find code duplicates in C# projects?

What tool would you recommend for finding code duplicates in C# code? ...

How do you refactor?

I was wondering how other developers begin refactoring. What is your first step? How this process (refactoring) differ if you refactor code which is not yours? Do you write tests while refactoring? ...

Code standard refactoring on large codebase

My studio has a large codebase that has been developed over 10+ years. The coding standards that we started with were developed with few developers in house and long before we had to worry about any kind of standards related to C++. Recently, we started a small R&D project in house and we updated our coding conventions to be more suita...

Where should I put "ugliness"?

Scenario: I have a function that I need to tweak in some way (example; make it work slightly different in different places). For some reason I end up having to add something ugly to the code, either in the function or at existing call sites. Assume that the sum total "ugly" is the same in both cases. The question is which choice should ...

"Rename control" in Delphi 7?

Following up on this question, I'm working on a large Delphi 7 codebase which was not written very nicely. I'm looking at code like this, as a small example: if FMode=mdCredit then begin Panel8.Caption:='Credit'; SpeedButton3.Enabled:=false; SpeedButton4.Enabled:=false; SpeedButton5.Enabled:=false; SpeedButton5.E...

Issues During ASP.NET MVC Upgrade from Preview 5 to Beta?

What issues or refactoring did you have to do when you upgraded from ASP.NET MVC Preview 5 to the newly released Beta version? ...

Could I improve this method with duck typing?

Hopefully I haven't misunderstood the meaning of "duck typing", but from what I've read, it means that I should write code based on how an object responds to methods rather than what type/class it is. Here's the code: def convert_hash(hash) if hash.keys.all? { |k| k.is_a?(Integer) } return hash elsif hash.keys.all? { |k| k.is_a...

Remove repetitive, hard coded loops and conditions in C#

I have a class that compares 2 instances of the same objects, and generates a list of their differences. This is done by looping through the key collections and filling a set of other collections with a list of what has changed (this may make more sense after viewing the code below). This works, and generates an object that lets me kno...

C to C translator / C-code cleanup tool

I wonder if there exist some free software that let me pass a C file and it outputs a more structured C-file. I'm dealing with a short piece of C-Code that has been written long ago. I'd like to extract a clever algorithm from it, but working with the code itself is hard because it lacks everything that makes C-code readable. Just a s...

refactoring stored procedure

I have a stored procedure currently executing a complicated fetch that is frequently timing out when used. The proposed solution in my department has been to simply increase the timeout time length; which I don't really want to do. I'd like to refactor this sproc, but because it's so complicated and undocumented (yay legacy systems) I'm ...

What GNU tools for refactoring are there?

How to refactor c source code that compiles with gcc, preferably a tool that can be used from the command line? ...

Refactor To Eliminate Repetition In Lamba Expression

These two methods exhibit repetition: public static Expression<Func<Foo, FooEditDto>> EditDtoSelector() { return f => new FooEditDto { PropertyA = f.PropertyA, PropertyB = f.PropertyB, PropertyC = f.PropertyC, PropertyD = f.PropertyD, PropertyE = f.PropertyE }; } public static Expre...

Is there a "right" way to do inheritance in JavaScript? If so, what is it?

I have been trying to learn how to add testing to existing code -- currently reading reading Working Effectively With Legacy Code. I have been trying to apply some of the principles in JavaScript, and now I'm trying to extract an interface. In searching for creating interfaces in JavaScript, I can't find a lot -- and what I find about ...

Incoming poplib refactoring using windows python 2.3

Hi Guys could you please help me refactor this so that it is sensibly pythonic. import sys import poplib import string import StringIO, rfc822 import datetime import logging def _dump_pop_emails(self): self.logger.info("open pop account %s with username: %s" % (self.account[0], self.account[1])) self.popinstance = poplib.POP3(s...

Automating code review and refactoring

I'm trying to do automated code review and refactoring with a tool. Something in the lines of FxCop or ReSharper. Looking for tool suggestions that meet these requirements: Low learning curve. Targeted at C# (and maybe VB.NET). Let's me easily add or customize rules (and understands entire CodeDOM). Well documented. FREE or dirt cheap...

How can I reduce duplication in constants?

I have this Perl script with many defined constants of configuration files. For example: use constant { LOG_DIR => "/var/log/", LOG_FILENAME => "/var/log/file1.log", LOG4PERL_CONF_FILE => "/etc/app1/log4perl.conf", CONF_FILE1 => "/etc/app1/conf...