I am currently refactoring an application which uses exceptions for logic flow. The code is difficult to read and maintain and makes a S.O.L.I.D fanboy like myself cry when reading it (not to mention the longest catch block I've ever seen in my career).
My question is what pattern(s) could you use to make it easier to maintain or how w...
I'm in the middle of performing a large refactoring which will involve renaming a lot of events. This will leave our code with a lot of code like this:
thing.NewEventName += thing_OldEventName;
How do I get a list of event handlers with nonstandard names in my code? Should I be thinking about a regex search, or should I be looking a...
So I have this stinky method, the two conditional blocks do almost the exact same thing, but with radically different parameters (at least in my eyes). I want to clean it Uncle Bob style, but can't for the life of me figure out a tidy way of doing it. So I come to you, my fabulous nerd friends, to see how you might distill this down to s...
This is a cross language question on coding style.
I have to work with a lot of code that has very long code blocks, sometimes hundreds of lines, inside if statements or for loops. The code is procedural.
Code like the following
if(condition){
//hundreds of lines of code
}else if{
//hundreds of lines of code
} else {
//hun...
The big question is are there any "built in" SQL Server 2005 functions to serialize / deserialize string parameters to a table variables? The rest explains my need further, but may not be necessary.
I have a SQL SP I would like to refactor. It currently accepts five customers ids and five sets of order ids relevant to those customers....
Hi, I am refactoring some code for an assignment - currently the view has lots of buttons and menus and one action listener which decides what to do by using event.getSource(). From what I've read people seem to think its better for each GUI component to have its own action listener, perhaps created through some kind of factory. However ...
Is there a tool that can run through a visual studio solution and adjust access modifiers to anything not being called in the solution is converted to private or internal where applicable?
I suppose I could just change everything to private, and then use the compiler messages and do it by hand...but that could take a while, if there was...
Hi, all.
I'm working on a spaghetti monster (unfortunately not of the flying variety), and I've got a question about proper design.
I'm in the process of taking a gigantic static Java method that returns an object and splitting it into reusable (and readable) components. Right now, the method reads an XML document, and then appends su...
As a developer that's used to static typing I usually let the compiler tell me if the code is correct, logic flaws excluded of course. But when refactoring PHP I find it is VERY hard to know that my code is correct.
There always seem to be some lingering reference to some method or member somewhere that get's broken and doesn't show up ...
I am parsing a file with python and pyparsing (it's the report file for PSAT in Matlab but that isn't important). here is what I have so far. I think it's a mess and would like some advice on how to improve it. Specifically, how should I organise my grammar definitions with pyparsing?
Should I have all my grammar definitions in one fun...
I have two similar classes, MultiSlotBlock and SingleSlotBlock. They have started to share a lot of common code so I have decided to do some refactoring and pull some of the methods up to a new superclass, let's call it Block.
Now one of the methods that I pull up, simplified for the example, looks like this:
// (Block.mm)
- (void)...
Let's say you got a project that is really poorly written, contains lots of code smells, wtfs, etc. Moreover, its code structure is so complicated that it is extremely hard to add any new functionality to it. On the other hand, the project works as it is supposed to.
You want to refactor the project, perhaps move it to a new framework, ...
I need to do some refactoring in Java, and I need to maintain some degree of binary compatibility. In this case I want to remove some legacy interfaces, that are not used anywhere anymore and which require a rather big (and also deprecated) external dependency.
I have class C that implements interface I, and I have code that calls a met...
In wanting to get some hands-on experience of good OO design I've decided to try to apply separation of concerns on a legacy app.
I decided that I wasn't comfortable with these calls being scattered all over the code base.
ConfigurationManager.AppSettings["key"]
While I've already tackled this before by writing a helper class to enca...
Is Refactor Pro the only .NET Refactoring tool that supports the String to StringBuilder refactor?
I'm looking for one that has a trial version of this feature to see if I like it enough to purchase. The overall goal is to tidy up another developer's VB.NET code.
...
I have this general problem in design, refactoring or "triage":
I have an existing multi-threaded C++ application which searches for data using a number of plugin libraries. With the current search interface, a given plugin receives a search string and a pointer to a QList object. Running on a different thread, the plugin goes out and s...
I am trying to extract out the common code pattern here in an extract method, but am having trouble finding the proper type for the type of Presenter. Any help?
public bool CanGotoHome
{
get { return !(CurrentPresenter is IHomePresenter) && IsLoggedIn; }
}
public bool CanGotoImportanceOfAimsAndObjectives
{
get { return...
So, i'm attempting simple card game. I have player "class" with draw function, and public members deck and hand, both are Arrays.
I need to draw a card from the deck, put it in hand and show it in player "hand" area. I'm concerned about the way I do "flip" and "play" buttons (through closures).
Here is the code:
littlegame.player.prot...
In Visual C# I can rename an entity at its definition, and with two clicks all references to that entity get updated. How do I do this in Visual C++? If it's not supported, is there another IDE that supports it?
Note that in the C++ case I also want automatic header/implementation synchronization, so I hardly ever need to do duplicate w...
Consider the following code:
>>> colprint([
(name, versions[name][0].summary or '')
for name in sorted(versions.keys())
])
What this code does is to print the elements of the dictionary versions in ascending order of its keys, but since the value is another sorted list, only the summary of its first element (the 'm...