Code Generator vs Code Refactoring
How do you like your CRUD programs. Code-generated, framework-driven, or manually written? ...
How do you like your CRUD programs. Code-generated, framework-driven, or manually written? ...
I'm a NetBeans 6.5 user and am searching for a way of generating a list of methods/classes that are not used within a set project group. I know I can right click on each method and select "Find Usages" but I'm looking for an automation to that process. I'm willing to look at something that runs outside of netbeans, as long as it genera...
So I'm refactoring a legacy codebase I've inherited, and in the process I found a static class that encapsulates the logic for launching 3rd party applications. It essentially looks like this (shortened for brevity to only show one application): using System.IO; using System.Configuration; public static class ExternalApplications { ...
I'm currently refactoring/tidying up some old C code used in a C++ project, and regularly see functions such as int f(void) which I would tend to write a int f() Is there any reason not to replace (void) with () throughout the codebase in order to improve consistency, or is there a subtle difference between the two that I am unaw...
Being that I'm a programmer, and programmers are lazy, I'm looking for a tool that can help me analyze code and refactor, decomposing conditionals mostly. I know that products like Resharper and Refactor Pro! can do this, but I was curious about FOSS alternatives. A Google search turned this nifty tool that creates flowcharts, has anyon...
I have enjoyed the power of NDepend ( http://www.ndepend.com/ ) when writing C#, but in my C++ projects I have not found a comparable tool. I use Visual Studio 2005, which has a class-view that covers some bases, but it is not powerful enough and doesn't work across project boundaries. I use Visual Assist X, which has some powerful refa...
I have inherited a project that uses the following pattern for passing parameters from the code behind to the aspx page. I know this is wrong, but I am on the fence on the best way to refactor it. Code Behind: using System; using System.Web; namespace BadPassing { public partial class _Default : System.Web.UI.Page { pr...
With my aspect, I track the changes on certain collections by advising certain method calls on instances of java.util.Set, notably add(Object) and remove(Object). Since the changes are not reflected in the collection itself, invocations of Set.contains(Object) or Set.size() return wrong results. Therefore I want to intercept all method ...
I want to re-write a method that has way too many nested if statements. I came up with this approach and wanted your opinions: public void MyMethod() { bool hasFailed = false; try { GetNewOrders(out hasFailed); if(!hasFailed) CheckInventory(out hasFailed); if(!hasFailed) PreOrder(out ha...
Ok I want some opinions how I can fix this mess of a method! It has WAY to many nested 'if' statements. But realize I have to know exactly where the method fails, currently in each of the respective 'else' clause I am logging the error (the failed 'if' condition'). Note: ignore any logic behind the things, please focus on the style an...
I have a very large app, 1.5 million lines of C++, which is currently MFC based using the Document/View architecture. The application includes a lot of 3d vector graphics, spreadsheets, and very many dialogs and Windows. Within the constraints of the DVA it is fairly well written, in that there is no significant program logic in the us...
Occasionally I come across methods with an uncomfortable number of parameters. More often than not, they seem to be constructors. It seems like there ought to be a better way, but I can't see what it is. return new Shniz(foo, bar, baz, quux, fred, wilma, barney, dino, donkey) I've thought of using structs to represent the list of ...
Are there any guidelines on writing database tests so that you can refactor database "without fear" while doing evolutionary database design? What aspects of database should be put to test while developing it? Any example would be great.. ...
We have a smelly code in our project. A lot of values which used in biz logic have 2 places where they stored: we have dictionary tables (used in FK relations) in DB where we stored values e.x. MessageDirectionInfo: 0|Unknown 1|In 2|Out and we have Enum with exactly same data: MessageDirectionEnum{Unknown=0,In=1,Out=2} And all over ...
Does anyone know of CSS refactoring tools? Ideally, I would load all of my CSS and have the tool intelligently remove redundant declarations, merge classes, etc, without completely munging it all. ...
Having read Fowler's "Refactoring" for a while, I still often catch myself thinking "I should have done this in smaller steps." -- even when I did not broke my code. Refactoring in small steps is safe, but cost time. It's a trade off between speed and risk -- I try to be strategic in choosing the way how I am refactoring. Nevertheless:...
In the book Clean Code: A Handbook of Agile Software Craftsmanship by Robert C Martin he advises that you should follow The Boy Scout Rule when maintaining code. The idea is simply to leave the code a little cleaner than you found it. I.e. it is very similar to the tip about not leaving broken windows from the Pragmatic Programmer book. ...
I have this problem. I can't stop myself from refactoring existing code that works but is, in my opinion (and perhaps objectively), badly designed or contains other "code smells". This can have a significant negative effect on my immediate productivity. But ultimately will be a big maintenance boon. If you also suffer from this "affl...
You have a method on a class that has 2 parameters, one of which is a file path, the other is irrelevant. InterestingResult result = foo.Bar(irrelevant, filePathInfo); In the spirit of having fast snappy unit tests, you find yourself considering refactoring this method to pull out the file path to remove the IO requirements of this te...
I just wrote this method: private String getNameOfFileFrom(String path) { int indexOfLastSeparator = path.lastIndexOf('/'); if (indexOfLastSeparator > -1) { return path.substring(indexOfLastSeparator + 1); } else { return path; } } The line that bothers me is: return path.substring(indexOfLastSeparator + 1); Is that a ba...