refactoring

Is there a useful scripting language to refactor code?

I've looked at JunGL, and it looks far too complicated for real use and is overly general. A tool like this would be useful for providing an alternative version of a language port, which would utilize more advanced language features/conventions. ...

How do I cancel an ajax call made using sajax?

Hi guys - a long while back when I built my first web application I used sajax by modernmethod to add ajax features to it. NOw its been a while and I have to clean it up a bit - I haven't set any real checks and my code of the time is terrible inefficient and to top things off it seems that sajax is dead? How do you cancel a specific a...

How to set JQuery .show / .hide without repeating Div selectors.

I want to pass this function a True or a False and have the elements listed show (true) or hide (false) on this input. I am currently using this function... function SetElementVisibility(visible) { if (visible) { $("#Div1").show("slow"); $("#Div2").show("slow"); $("#Div3").show("slow"...

Shorten JavaScript

Hello, I got some help a few weeks ago on some code for a drop down menu but I am wondering if it is possible to make the code shorter because the current code shown below is quite big, any help would be great. $(document).ready(function(){ $("#zone-bar li em").mouseenter(function() { var hidden = $(this).parents("li").children("...

Refactoring inheritance to composition using Vbex2005

I have a class that I wrote fairly early on in my vb.net programming experience which inherited from another class it really should have composed. The base class is a relatively generic nested dictionary-based collection; let's call the descendant class a "Car". Right now there's a lot of code that does things like 'MyCar!Color.st = "R...

Conversion VB -> C #. Regular expression to modify ("abc") in ["abc"]

Hi We are currently converting our old base VB.Net to C #. Converting the bulk of the code is not a problem .. there are good converters around. The problem we are facing is that none of the tested converters can convert () in [] in arrays and collections. Example: Session ("abcd") to Session ["abcd"];. Converters think Session is a me...

Is it acceptable having parameter in class constructor?

Guys for wc, a rubygem I'm writing and that is useful for counting word occurrences in a text, I choose to put 3 parameters in class constructor. The code is working, but I want to refactor it for niceness. In your experience, it's easier to read/mantain/use as API a class with a constructor with no params and a lot of setters/getters m...

What is the best way to DRY up these classes, duplication in everything but constructor

So I did some refactoring and two of my classes now look exactly the same except for their constructors. The classes wrap an API object that isn't very pretty, and add some functionality that belong at the edge of the API. class A extends API { public A { this.APIOption = Option1; this.AnotherAPIOption = Option2; // a few...

How to Optimize this method

private static void ConvertToUpper(object entity, Hashtable visited) { if (entity != null && !visited.ContainsKey(entity)) { visited.Add(entity, entity); foreach (PropertyInfo propertyInfo in entity.GetType().GetProperties()) { if (!propertyInfo.CanRead || !propert...

Is it possible to simplify (refactor) my Pizza Program code (VB.Net 2010)?

I have created a simply Pizza program (for a summer project not education related) that uses check boxes to determine what the customer wants. Basically a simple pizza ordering program. I was wondering as I have used the If statement over and other again for different parameters and variables, is it possible to use multiply arrays to sim...

My Python Program Files cleaner, a better way to write this?

Similar to my other post I have created a new little utility and wanted to get some feedback if there is a way to make my script more Pythonic per say. It is a simple tool for Windows that removes empty directory from the Program Files directory because sometimes programs leave behind an empty directory when they uninstall. import os d...

Writing a simple custom read more on click function for jquery that needs refactoring

I want to be able to reuse the same function many times on one page.. So here's some psuedo-code : $(".read_more").click(function(){ $(this).parents().find(".hidden_text").slideToggle("fast") }); The problem with this code, however, is that it targets every elem on the page matching .hidden_text. Is there a way to combine closest() w...

Adding features to code bases which are in dire need of refactoring

I am developing on a system that is a bit difficult to work with. It is 99% undocumented, does not follow best practices and is fairly difficult to understand (globals galore, methods spanning 50 lines, eval abuse, etc.). Unfortunately, I am fairly new to the code base and I need to add functionality. I am sure there is code in there th...

PHP Static code Analysis - Finding Class Dependancies

Hi, I am about to start a large refactoring job on a big PHP project. I have successfully used pdepend to generate dependancy reports on the packages outlined in the PHPDoc blocks at the start of every file. The information is really usefull, it outlines dependancies between packages (which packages are used by which, cyclic dependanc...

"Test Driven Development" Refactoring Design Complexity

Hi all, I am currently studying test driven development. I am inquiring about an improvement in design if we refactor after the development of every couple of units as opposed to dedicated refactoring sessions that are more spaced apart in time. I am aware that the technical debt will be larger. But I am wondering what other impacts. ...

How to change the name of a database model and table in Rails?

Lots out there about changing model names only or mapping new models to existing tables, but nothing about renaming both at the same time. For now, I'm starting with the DB table and working my way out with Find/Replace in my code, but I'm surprised there isn't something better or at least someone who's tried it and written about it. ...

Purging Preprocessing Macros

Hi! This is an odd problem, so I have to provide a bit of background. I have a C++ project that I'm working on that I want to clean up a bit. The main issue that I'm dealing with that makes me want to barf is the massive abuse of preprocessor macros that are used in a core component of the project. There's a file with a bunch of #define...

Xcode is stuck when trying to refactor a class

Hi, Xcode gets stuck if I try to rename a class via refactoring. It shows "Applying Changes" window and says "Please wait while changes are made." But changes are never made. It's stuck! How can I solve this problem? ...

Batch refactor "using" statement declarations in C# across multiple files

I have a bunch of c# code I inherited that has "using" statement declarations like this using Foo; using NS1=Bar.x.y.z; and I've been asked to make our codebase consistent with regard to namespacing - the policy is simply that 1 some namespaces should always be fully qualified (no aliases) - for example things inside "Foo" above sh...

OK, so I'm not a beginner anymore. What comes next?

In a certain sense, I'm still very much a beginner, but I don't need to read C++ Primer or Learn C++ in 21 Days, or at least, I only take a peek every now and then for reference's sake. So what is my problem? Basically, I started to write a small game to help my process of learning. Along the way, I've learned most of anything that you ...