refactoring

How to refactor Netbeans generated GUI code?

I had created a GUI in Netbeans through Netbeans Swing GUI creator. So I just dragged and dropped the Swing Components from the "palette" window and all the code was generated by netbeans. Now the code is too long to maintain (approx. 10,000 lines). So some experts on SO suggested me to refactor my code. I can refactor the code that wa...

Confusion between whether a code should be executed by EDT (Event Dispatch Thread) or not?

I had developed a Swing GUI which contains 12 JPanels. Initially, all the JPanels code was written in the main JFrame class code. As a result, the code became too long (10,000+ lines). Now I want to refactor the code to break the code into 13 classes (12 classes each for one JPanel and 1 class for the main JFrame)instead of 1 class carr...

cost to refactor on medium sized freelance projects

I've been working on a freelance project for about a year. I build a new feature every month as per client request. Things went smoothly the first several months. I built each new feature as a separate module. But today, there are too many different modules for me to manage and new developers on the project are confused by the comple...

Refactoring Service Layer classes

My company is on a Unit Testing kick, and I'm having a little trouble with refactoring Service Layer code. Here is an example of some code I wrote: public class InvoiceCalculator:IInvoiceCalculator { public CalculateInvoice(Invoice invoice) { foreach (InvoiceLine il in invoice.Lines) { UpdateLine(il); ...

What is the name of the question mark in my URL?

http://example.com/foo.aspx?foo=bar I'm refactoring and need to name the constant which will hold only the question mark character of this string. I'm not sure what best to name the variable, as I've never known what the proper name of that question mark was. What should I name the constant? Or... is there something in .NET that's th...

How to validate that a Refactoring is equal to original code.

I'm working with legacy java code, without any Unit-Tests. Many classes need to be refactored in order to work with the project. Many refactorings can be done with eclipse, and am I doing some by hand. After some refactoring I review the diff to cvs-HEAD, but i can't really feel certain that everything is 100% correct. The Question: ...

Reporting Stored Procedure - How to avoid duplication?

I'm writing a reporting stored procedure. I want to get the number of non-Acknowledged and non-Invoiced Purchase Orders, with the ability to (optionally) filter on CustomerID. What I have below works as expected, but I worry that a) it's slow and b) there's duplication in the CustomerID portion of the WHERE clause. How would you write...

Automatically remove explicit package declarations with import statements in Java

Hello, I have a project created by others that includes thousands of class files and has the package names explicitly typed out for every reference to any of their classes. It looks like the code was reverse engineered. Is there a good tool for Java that refactors the code so that the explicitly typed package prefixes are removed from c...

In agile development how do you deal with the "less-well-architected" code that results from a sprint-focussed mindset

I work on an agile project using Scrum. Sprints have come and gone and we have fulfilled milestones successfully. The system works well enough to meet the current customer requirements. However, we are left with a system in serious need of refactoring, as much of the development was performed with little eye on the future (instead the...

java: refactoring case (M and C of MVC?)

I have a situation in Java where I have an external device that I want to communicate via serial I/O. I know how to do this, but I'm now in a refactoring mode to make sure I've got a maintainable software package, & was looking for advice on what to do / not to do at a high level (specific questions below) Conceptually, let's say I have...

Call graph of the whole application

Hi all, Is there a non-toyish tool that can create a call graph of the whole application? I don't mean just getting a picture or drawing call graph by means of pointing method-by-method. I need a call graph, which is accessible programmatically, i.e. the tool should flush it to a file in text mode (e.g. XML) or build the call graph in ...

How should I refactor my code in this case?

I'm currently using Qt's QTextStream to read many different types (read: different extension) of text files. Each "FileReader" class I create starts to have a similar pattern where it needs to readLine() like this: // Get the line's first word as float where each word is delimited by a comma fileData.readLine().split(",")[0].toFloat();...

Java: Are there some tools out there which are able to refactor X[][] to List<List<X>>?

Hello, everyone! I have to refactor an existing project, which is not that small. It contains a lot of arrays declarations and accesses: (X is not a generic type, it's just a placeholder). declarations: X[] and X[][], access: someArray[i] and someArray[i][j]. I have to rewrite everything to use generic Lists: declaration: List<X> and L...

C# ASP.NET Refactoring Codes | How To/ Guidelines

I am facing with a huge task at hand, start re-factoring our biggest asp.net web which created from asp classic, then ported to asp.net VS2003 and then later on ported on asp.net VS2005. Where codes are old school, all business logic & data access are all to be found on the .aspx.cs files. The good thing is, it is working A-Ok. Now my q...

Is there a way to force OracleCommand.BindByName to be true by default for ODP.NET?

Since the System.Data.OracleClient library has been deprecated, we are in the process of migrating our code base to use Oracle Data Provider for .NET (ODP.NET) instead. One of the issues that we have encountered is that the System.Data.OracleClient uses parameter name binding as opposed to binding by position and all of the code directly...

Generate Call-Tree from cscope database

I want to generate Full and Partially Call Trees from cscope database of c and c++ projects in Linux. The project is rather large, so it can be not easy to work with the full call tree of project, so I want to limit call tree generation with grep-like filter of function names. And also I want to be able to build "called by" and "called...

Which function architecture is the best for maintainability in this simple case?

I'm adding "promo code" functionality to an online shopping cart written by someone else. This is a pretty micky mouse architecture question, but I would like to hear a couple of opinions. All three of my ideas would work, but which do you think is best for maintainability? So, here's the basic table structure for the promo codes: CR...

Eliminating code duplication in a single file

Sadly, a project that I have been working on lately has a large amount of copy-and-paste code, even within single files. Are there any tools or techniques that can detect duplication or near-duplication within a single file? I have Beyond Compare 3 and it works well for comparing separate files, but I am at a loss for comparing single ...

Why is this code slower even if the function is inlined?

I have a method like this : bool MyFunction(int& i) { switch(m_step) { case 1: if (AComplexCondition) { i = m_i; return true; } case 2: // some code case 3: // some code } } Since there are lots of case statements (more than 3) and the function is becoming large, ...

Is there a tool for refactoring SQL, a bit like a ReSharper for SQL

The sort of stuff I'm after right now is quite basic: Auto format Detect ununsed variables Variable naming convention checking I wouldn't be surprised if there was a tool available that could handle more complex refactorings such as those found in Refactoring Databases, but I appreciate that the added complexities introduced by curr...