Goals of refactoring?
What are the goals of refactoring code? Is it only to enhance the code structure? Is it to pave the way for future changes? ...
What are the goals of refactoring code? Is it only to enhance the code structure? Is it to pave the way for future changes? ...
hi guys, i'm currently working on a perl web app LAMP style and recently stumbled upon this death maze of code left by some previous developer. He left so many magic numbers and weird logic that it's gives me a headache everytime i had to go through it. I'm learning unit testing right now so i want to find some useful tool to refactor t...
I'm using the following function to map columns from a DataTable (passed from the data tier) to object properties. The function exists within the class I'm populating. The class has two methods: Load() which loads the object with values and LoadAll() which returns a collection of populated objects. I wanted to be able to use the same cod...
I find that I often descend into what I call "rabbit holes" as I learn about a new technology/language/method/etc. These are the moments where you feel that in order to understand a detail of what you are working on, you start investigating and investigating and you end up in a related, but detached space. For instance, I'm learning Ru...
Personally, I've always put unit tests in a separate project just because that's how MSTest seems to be set up. But I'm reading Refactoring: Improving the Design of Existing Code by Martin Fowler and he seems to be advocating not only putting them in the same project, but also putting them in the same class as the method they're testing...
Why does Visual Studio by default create a private static method when refactoring code and selecting extract method? If I'm refactoring a non-static class and the method is only visible within the class why is it static? Is there some performance benefit by calling a private static method within a non-static class compared to a non-sta...
I'm building a MySQL query to determine how many items from each of several categories appear in a given date range. My initial attempt looked like this: select Title, (select count(*) from entries where CategoryID=1 and Date >= @StartDate and Date <= @EndDate) as Cat1, (select count(*) from entries where CategoryID=2 and Da...
I have found that when I need to rename a Java class (and therefore the source file) or need to change the package name (and therefore move the source file[s]), I can either: Use the nice and useful Eclipse refactoring tools which is great since all the cascading tasks are done for me. However, I then have an uphill struggle with Subve...
One of the things I love about Visual Studio 2008 is the ability to refactor and reorganize the "using" statements in source code files (this may have been in 2005 as well, I don't remember). Specifically, I'm talking about how you can have it both reorganize the statements to be alphabetical (though with the core FCL libraries floating...
Will it be easy for a C++ developer to read Refactoring: Improving the Design of Existing Code Is there any other book that I should read about refactoring? Feel free to add any articles on refactoring. ...
I am working on modifying a control on a existing site. All controls from the site inherit form a base class. I have a requirement to hide several links on the master page so I wrote this method on my control: private void HideCartLink (bool visible) { Control control1 = Page.Master.FindControl( "link1" ); control1.Visible = visib...
Having just read the first four chapters of Refactoring: Improving the Design of Existing Code, I embarked on my first refactoring and almost immediately came to a roadblock. It stems from the requirement that before you begin refactoring, you should put unit tests around the legacy code. That allows you to be sure your refactoring di...
Yet another argument with a friend of mine. Consider this code: class User < ActiveRecord::Base has_many :groups def in_group?(group) groups.include?(group) end end class Group < ActiveRecord::Base has_many :members def add_user(user) members << user end end My opinion is that these methods add extra unnecessar...
I feel the need to refactor my old CF5 based code into CFC's. We already have some code in ColdSpring and Transfer but feel a large rewrite to ColdSpring and Transfer is pointless. What tips, approaches and gotchas will I hit. How can I make this easy? I don't mind keeping ColdSpring in the mix but Transfer is the bit I'm scared of...
Does anyone know of an automated approach to refactoring code to minimize the visibility of classes, and their properties and methods? I'm trying to clean up an old API that has way too many public getters and setters to fit with JavaBean standards. An Eclipse plugin would be ideal, but any tool that could help would be great. ...
I am using C# 2.0, and I can't help but think this isn't the most efficient way to search a collection (in this case a DataTable) for a value: bool found = false; foreach (DataRow row in data.Rows) { if (id == row["rowID"]) { found = true; break; } } if (!found) { //Do stuff here } Can anyone think of a...
I've been spending some time refactoring my C# code, and I'm struck by how large my parameter lists are getting for local variables, especially when you start getting several levels deep and have to pass local variables from higher up the call stack. As an example, I have some rather complex code that uses Linq to sql. I instantiate a ...
While refactoring some C# classes, I've run into classes that implement IDisposable. Without thinking, I have created partial class files for each class that implements IDisposable interface. E.g.) For Stamper.cs -> Stamper.cs + Stamper.Dispose.cs where Stamper.cs contains actual logic for stamping and Stamper.Dispose.cs that contains...
I've installed the Web Tools Project for Eclipse version 3.4. I've been trying to get refactoring working the way I think it should and have had no success. I have one Java project that contains the Java classes for the jar that is put into the /WEB-INF/lib for a web site. Another project (a Dynamic Web project) has the JSP files for ...
I have a custom class file in C# that I inherited and partially extended. I am trying to re factor it now as I have just enough knowhow to know that with something like generics(I think) I could greatly condense this class. As an inexperienced solo dev I would greatly appreciate any direction or constructive critism any can provide. ...