I have a large class with lots of methods and it's starting to get a bit unorganized and hard to navigate. I'd like to break it up into modules, where each module is a collection of class and instance methods. Perhaps something like this:
UPDATE: I've now realized that this is a pretty poor example. You probably wouldn't want to move va...
I have a method where performance is really important (I know premature optimization is the root of all evil. I know I should and I did profile my code. In this application every tenth of a second I save is a big win.) This method uses different heuristics to generate and return elements. The heuristics are used sequentially: the first h...
I have a bunch of rails models that i'm re-writing into a single model to simplify my code and reduce unnecessary tables.
I'm wondering what the best way to delete a model class and its table is. I want past migrations to still succeed, but I don't want to leave the empty models lying around. Do I have to manually delete the old mig...
I have a class for products import from CSV file operation which requires about 7 parameters. This is an info which is definitely needed for importer.
All of this parameters have the same life time. In the end we must have an Immutable Object.
I was too scared to list all of them in constructor because of its affect to readability and ...
Right now I use the parameter object's class to be inherited like so
class A():
def __init__(self,p1,p2):
self.p1, self.p2 = p1, p2
class B(A):
def __init__(self,b):
self.p1, self.p2 = b.p1, b.p2
This trims up the absurdity of using the code but not the class code itself. So, I'd like to do the C++ thing and p...
I have a lot of code in the admin area of my site that is, basically just CRUD operations using AJAX posting.
I was wondering if you had any tips on refactoring these type of functions either into generic functions or classes etc.
Here is some sample code, though a lot of this is duplicated in other functions with just different ajax p...
I'm thinking there has got to be a cleaner way to check if a regular expression is not nil / is true. This is what I have been using:
hold = (h4.text =~ /Blah/)
if !hold.nil?
...
end
I tried: !(h4.text =~ /Blah/).nil? but it did not seem to work.
...
I've searched a little bit around SO and haven't found any questions/answers that are helping me. The problem is my jQuery function calls are getting much too large to maintain. I'm wondering if I should be refactoring a lot more or if there is a better way to do all of these calls. You'll see as I make one call, the anonymous functio...
Select a method
Edit > Refactor...
Select "Move Up"
I get the following error a lot.
Any ideas on how I can get Xcode to, well, do its job?
Solution Summary
Option 2 that Peter suggests below did the trick. I can't believe that
a) I didn't try this Smacks head
and
b)
Xcode couldn't find a sane way of saying "Don't select th...
In a test method (for a Fluent NHibernate mapping, although that's not really relevant) I have the following code wrapped in a bunch of usings and try/catch blocks:
new PersistenceSpecification<Entry>(session)
.CheckProperty(e => e.Id, "1")
.VerifyTheMappings();
I would like to refactor this so that I can pass it to a helper m...
hi i want to take out the common content in the 2 FACES JSPS and put in one jsp and include two tabs in that FACESJSP and those two tabs will show the differet content any help with sample code pls?
...
Recently I inherited a business critical project at work to "enhance". The code has been worked on and passed through many hands over the past five years. Consultants and full-time employees who are no longer with the company have butchered this very delicate and overly sensitive application. Most of us have to deal with legacy code o...
Currently I have code like the following (simplified somewhat). Eventually, I've added more and more new classes like D1/D2, and I think it's time to do some refactoring to make it more elegant. The goal of course is to make adding new class Dx use as little duplicate code as possible. At least, the duplicate parts of calling FileImporte...
I have a self-contained solution (non of the DLLs are used in any other project, so no worrying about Methods being used somewhere else).
I'm trying to figure out a way to determine every method/property that is not in use at all.
So I can't just look at private methods/properties, I need to also check Public methods and Properties.
I...
Any ideas on a good way to refactor this so that my code acts the same, but without the whole throwing and catching my own exception?
public Int32 ChooseNextColor(Int32 numColors)
{
int? nextColor = null;
while (nextColor == null)
{
Console.Write("Please enter your next color selection: ");
string input = Co...
I want to extract the guard statement from the following method
private void CreateProxy()
{
//extract the following guard statement.
Host selected = this.comboBox1.SelectedItem as Host;
if (selected == null)
{
return;
}
this.SearchProxy = ServiceProxy.ProxyFactory.Cr...
Hi all,
EDIT:
What is the best way to structure complex applications with CodeIgniter? To make this question more specific, maybe to just focus on structuring controllers: If you have a Users controller, than should all functions be in this one file? In other words, you might have controller actions that tie to specific views, but a ...
I have a class that extends PDO to give it the ability to pull the configuration from an xml file. Unfortunately the our hosting provider has disabled SimpleXML so I need to refactor my code to use Dom, which is available.
I am using the following code:
class xmlPDO extends PDO
{
public function __construct($xml_uri){
$xml...
I am refactoring java 1.3 legacy code, around 700 classes.
Due to the lack of generics in this code I see currently thousands of warnings, which of them should I simply disable? I don't wan't to discuss of every single warning, just a rule of thumb in terms of groups displayed in eclipses the errors/warnings dialog.
...
I don't want tools for actually performing refactorings, but tools for finding and suggesting potential refactorings. Particularly tools for identifying blocks of code that are similar and could be merged into a utility functions.
The background here is that I've been asked to investigate reducing the code size of an embedded C system. ...