refactoring

Refactor for Speed: Convert To a Date

Hello, I work for myself, I am a self-employed coder and as a result I don't have the luxury of code reviews or the ability to improve based upon peer programming. I am going to use this as an exercise to see if the StackOverflow community might help to review a simple method which i've written; internal static DateTime CONVERT_To_D...

Rails: Refactoring, views, helpers: how does it all go together?

Warning: Noob here. I know this is a trivial subject but I'm having a lot of difficulty in figuring out how exactly I can simplify my views by moving parts of them into helpers. For example, I've always read that conditionals in your views are prime candidates for extraction into helpers, but I couldn't really find examples of this, and...

Change classes in Java

Hello Folks I have a class ImageA, and a class ImageB. The both classes represents an image in my app, but each one in a different way. Even being different, their constructors are equal, and both have the method compare. So, what I done was creating a class Image, and ImageA and ImageB are subClasses of Image. public abstract class I...

Can this Sql statement be refactored to NOT use RANK/PARTITION?

Hi folks, I have the following sql statement, which works perfectly fine. I was hoping to see how this could be refactored so it doesn't require the use of RANK/PARTITION ... if possible. SELECT LogEntryId, FileId, CreatedOn, EventTypeId FROM (SELECT a.LogEntryId, a.FileId, a.CreatedOn, a.EventTypeId, RANK() OVER (PARTITION B...

Is there any tool that can analyze the dependencies between variables in c# programs?

There are many tools that we can use to show the dependencies between modules, source code files, classes, or functions etc. But there seems no tool for analyzing the dependencies between variables. Given a dependency graph of variables would be helpful for understanding and refactoring the code. For example, if variable b is only used ...

Refactoring Fun - Prime Numbers

Hi From Uncle Bob's book Clean Code (example was in Java, so this was my first java translation), I've been playing with the refactoring example on prime numbers. The question is: How would you refactor the following code? There are 4 versions here: UglyVersion :-) , BobVersion, PeteVersion, PeteVersionClassMember. I'm doing th...

help me "dry" out this .net XML serialization code

I have a base collection class and a child collection class, each of which are serializable. In a test, I discovered that simply having the child class's ReadXml method call base.ReadXml resulted in an InvalidCastException later on. First, here's the class structure: Base Class // Collection of Row objects [Serializable] [XmlRoot("Ro...

JQuery refactoring help needed

Hi all, Here's my javascript code: <script type="text/javascript"> $(document).ready(function() { var currentInput = ''; var currentLabel = ''; $("#userLookup").click(function() { var url = "<%= Url.Action( "ListAll" , "User") %>"; currentInput = $("#User"); currentLabel...

Is it reasonable to have a fair amount of public properties in a class?

Or in more specific words, is it "ok" to not be relying on setters and getters? I'm dealing with a class that checks the availability of rooms and sets public properties of which there are more than a dozen. Things such as: unitNumber roomTypes ( array ) codeCorporate codeGroup numberKids numberAdults numberRooms currency minRate maxR...

How do I disable automatic save after refactoring in Eclipse?

When I ran the Inline and Extract Local Variable refactorings, Eclipse saved my file immediately after. Also, Undoing/Redoing these refactorings resaved the file each time. How can I disable this behavior? Secondary question: Running Extract Method didn’t automatically save the file. Why the inconsistent behavior? ...

Which tools can help in translating (as in french -> english and not C++ -> java) source code?

I have some code that is written in french, that is the variables, class, function all have french names. The comments are also in french. I'd like to translate the code to english. This will be quite a challenge, since it's a 18K lines project and I'd like to know if there is any tool that could help me, especially with the variables/cl...

Is there a 3 way merger tool that “understands” common refactoring?

When a simple refactoring like “rename field” has been done on one branch it can be very hard to merge the changes into the other branches. (Extract method is much harder as the merge tools don’t seem to match the unchanged blocks well) Now in my dreams, I am thinking of a tool that can record (or work out) what well defined refactorin...

Is there a source code control system that understands/records c#/vb.net factorings and how to merge them?

MolhadoRef is a refactoring-aware SCM tool that is capable of capturing and versioning of the semantics of Java program entities and refactoring operations that were performed on those entities. Does anyone know of such a system in the .NET universe? (Why is it that .NET always seems to be way behind java with the type of ...

How should I refactor my class?

Basically I have a class that sends a SOAP request for room information receives a response, it can only handle one room at a time.. eg: class roomParser { private $numRooms; private $adults; private $dailyPrice; public function parse(){} public function send(){} }; $room = new roomParser( $arrival, $departue ); $...

Is there a refactoring tool that works across solutions files?

All the refactoring tools for C# and VB.Net that I have seen only consider the source code in a single visual studio solution. For better or worse, our large (many related programs) system is spread over many solution files, however: All the code is below a single windows folder. Our nAnt based build system, builds all files in a win...

How do I refactor data contracts in WCF services?

We have lots of WCF services that are only used by our own code; the code that uses them is mostly in the same solutions files that contains the services. However they do not use a shared assembly for the contracts, so each time a data contract is change the reference to the service has to be updated by hand in all projects that use the...

How do you cleanly separate code for backwards compatibility from the main code?

I'm interested in what strategies people have come up with for separating all the crufty logic that's necessary to maintain backwards compatibility from the main code of an application. In other words, strategies that let you come closer to having your code look as if there were no backwards compatibility concerns except for separate iso...

Data model refactoring for Rails-based fundraising event registration/pledging site

I'm re-factoring a semi-successful Rails-based event registration and pledging system for a particular fundraising event for a non-profit. The existing data structure is rather ungainly, though it captures all necessary details and relationships. I would plan to refactor this in any case, but since I've also been asked to allow for mul...

OO Design Question

Looking for opinions on this: I have broken out various responsibilities into separate objects. However, many of these objects have dependencies on each other. All of these objects are adhering to interfaces so I'm not tied to an implementation. I'm concerned about the dependencies between objects and the potential for circular depen...

How to refactor log4net statements in c# ?

Ok so after reading danben's answer on this post, I guess I'm convinced of the need for writting this kind of code, atleast in a lot of cases. My managers seem to be agreeing too. if (log.IsDebugEnabled) log.Debug("ZDRCreatorConfig("+rootelem.ToString()+")"); if (log.IsInfoEnabled) log.Info("Reading Configuration . . ."); T...