I've come across a switch statement in the codebase I'm working on and I'm trying to figure out how to replace it with something better since switch statements are considered a code smell. However, having read through several posts on stackoverflow about replacing switch statements I can't seem to think of an effective way to replace thi...
We are in the process of refactoring some code. There is a feature that we have developed in one project that we would like to now use in other projects. We are extracting the foundation of this feature and making it a full-fledged project which can then be imported by its current project and others. This effort has been relatively st...
I have been using CakePHP for a few weeks now and its been an great experience. I've managed to port a site surprisingly quickly and I've even added a bunch of new features which I had planned but never got around to implementing.
Take a look at the following two controllers, they allow a user to add premium status to one of the sites l...
Ever since I gained experience at a software house I have found it difficult to tolerate code not neatly structured, without any form of architecture or beauty or clarity whether or not it works i.e. does what its supposed to do.
I find I am always caught up in refactoring code like this sometimes "at my own expense" is where my comfor...
Sometimes I want to attach an event handler but I'm not sure if I've done it already to that object. My workaround is to remove it using -= then add it using += . Is there a better way?
Edit: The reason I want to make sure not to do it twice (or more) is that if I do, it will get fired twice (or more)
...
I have a complex RIA client that communicates with a WCF SOAP web service, the second a being the operative word. This has resulted in a dreaded god class containing 131 [OperationContract] methods so far and even more private methods.
Personally, I don't have a problem with this; I use search and the navigation features of Visual Stud...
I work at a site that passed through some face lifts. In time the CSS files became pretty massive, as the CSS for the old designs was not deleted when no longer needed.
I was wondering if there is some kind of tool that allows me to spider the entire site(or the source files) and check which css rules are no longer used.
I know that t...
I need to rename all of my tables, stored procedures and obviously the code within each stored procedure that was referencing the old table names.
Why is the best way to do this?
Some methods I have considered:
SP_Rename - Gets half the job done. However this doesn't change the code within the SP itself
In addition to RedGates' Refa...
In the near future, I will be inheriting a somewhat large project. I've been making some small updates to it recently, and noticed that parts of it could use some refactoring, since there are methods that perform the same operation with a small difference.
I was wondering if there is a tool that will take a bunch of source code and f...
I have a great number of methods like this:
def enableMotors
@posIface.Lock 1
@posIface.data.cmdEnableMotors = 1
@posIface.Unlock
end
def goTo (pos)
@posIface.Lock 1
@posIface.data.cmdVelocity.pos = pos
@posIface.Unlock
end
I would like to create functionality to :before_filter and :after_filter or any other way I can kee...
I have the following code I want to run, but the problem is $this->type is set when the class is created by specifying either petition, proposal, or amendment. As you can see my $sql statement is a UNION of all three, and I want to specify which table (pet,prop,or amend) each row of data comes from.
public function userProposals() {
...
I need to understand and clarify some T-SQL stored procedures that contain important business logic. Does anyone know of any tools, tips, tricks, or hints that can be used for unit testing so I can refactor this sql without breaking it?
...
I have changed a column name in a table in my SQL Server 2005 database. I also have a rather large collection of stored procedures that may or may not be referencing that column. Is there a way to find what stored procedures are referencing that column without actually going through each stored procedure and search for it manually? Is...
I've created a function that scrolls a given child element into view within its parent. It goes as follows:
function keepScrolledOver( elem )
{
frame = elem.parent();
var scrollPos = frame.scrollTop();
var offset = elem.attr( "offsetTop" );
// If the element is scrolled too high...
if( offset < scrollPos )
{
frame.scrollTop( ...
Emacs and Java change propagation
Hi,
I'm mostly used to code in IDE like Eclipse but I wanted to try emacs. Because I keep hearing about how much better it is than big IDE like Eclipse and Visual Studio.
So I was looking at what emacs provides for Java (with the JDEE extension) but it doesn't seem as complete as Eclipse.
One of the m...
I want to see which classes are implement from a particular Interface. I know this is possible with the Eclipse by saying "Type Hierarchy View". Is is possible in VS 2008?
I guess that it may be possible with Resharper. But without it, is it possible? Any workarounds?
Thanks
...
Hello,
For one of my clients, I am generating a clients list from the Django Admin. It splits the clients by status: current, acquired, and past.
Currently, the view code for that list is as follows:
def clients_list(request):
current_clients = Client.objects.all().filter(status='current')[:10]
acquired_clients = Client.objects.all()....
Hi all,
I am in the process of refactoring 4 disparate software components that pretty much do the same thing into a single service (not a web service - necessarily or even likely). 3 are written in C++ while the last and most important is written in Java. The rest of the system is written in Java and therefore I will not be refactoring...
I'm currently present with the following situation.
We have a huge enterprise application written with WebForms. Refactoring it or completely rewriting it is out of the question. So I'm not talking about migration WebForms -> MVC.
However, I understand one can technically add MVC functionality to coexist with the rest of the project. I...
I am in the midst of refactoring my database to support an upgrade to our web-based tool.
Imagine that I have four tables: Milestones, Categories, Skills, and PayRates. Under the old schema, each of these tables only listed a name, and that name was the key for the table.
Under the new schema, each table has not only a name, but also ...