I've been looking for a good PHP ORM tool to use, and I recently found a good ORM class in Kohana. It has a fairly good and simple ORM implementation. The problem is, the code is unreusable outside of the Kohana framework without a rewrite/refactor. It relies on the Kohana class loader and various framework loading strategies to even wor...
I've heard that projects developed using TDD are easier to refactor because the practice yields a comprehensive set of unit tests, which will (hopefully) fail if any change has broken the code. All of the examples I've seen of this, however, deal with refactoring implementation - changing an algorithm with a more efficient one, for examp...
Java is nearing version 7. It occurs to me that there there must be plenty of textbooks and training manuals kicking around that teach methods based on older versions of Java; where the methods taught, would have far better solutions now.
What are some boilerplate code situations, especially ones that you see people implement through fo...
In The Guerilla Guide to Interviewing Joel says that guys who want to get things done, but are not smart will do stupid things like using a visitor design pattern where a simple array would be sufficient.
I find it hard to detect, if the design pattern suggested by the Gang of Four should be applied.
Therefore, I would like some exampl...
I control access to some of my static web resources with some PHP logic. Because directory-based authorization through the webserver is not suitable or easily possible.
A combination of things determines whether access is granted or denied. And these rules change from time to time.
In the beginning it was a simple regex path match, a...
I have a lot of assignments where I have to continually update a Makefile as I add more subsequently numbered C programs. Is there a way to do this with a loop which iterates over the values 1.1, 1.2, 1.3, etc.?
all: 1.1 1.2 1.3 1.4 1.5 1.6 1.7. 1.8 1.9
1.1: 1.1.o
gcc -o 1.1 $(FLAGS) 1.1.o
1.1.o: 1.1.c
gcc -c $(FLAGS) 1.1.c
1...
Hi, I have a page on which I must load controls dynamically based on the user selection.
Let's say that I have something like this:
public static readonly Dictionary<string, string> DynamicControls = new Dictionary<string, string>
{
{ "UserCtrl1", "~/Controls/UserCtrl1.ascx" },
{ "UserCtrl2", "~/Control...
Sometimes you have strings that must fit within a certain pixel width. This function attempts to do so efficiently. Please post your suggestions or refactorings below :)
function fitStringToSize(str,len) {
var shortStr = str;
var f = document.createElement("span");
f.style.display = 'hidden';
f.style.padding = '0px';
...
I'm currently refactoring code to replace Convert.To's to TryParse.
I've come across the following bit of code which is creating and assigning a property to an object.
List<Person> list = new List<Person>();
foreach (DataRow row in dt.Rows)
{
var p = new Person{ RecordID = Convert.ToInt32(row["ContactID"]) };
list.Add(p);
}...
As a growing dev team we are beginning to encounter the problem of rewriting functions that behave in similar/identical ways.
We are all guilty of failing to write documentation as time is a limiting factor, however the idea of gathering all current functions (duplicates and all) and using that list along with applied key words and the ...
Our coding standards ask that we minimise the use of C# var (suggests limiting it's use to being in conjunction with Linq). However there are times when using generics where it's reasonably convenient e.g.
Dictionary<DateTime, Dictionary<string, float>> allValues = ...
// ...
foreach (var dateEntry in allValue)
is easier to type
for...
We've trying to separate a big code base into logical modules. I would like some recommendations for tools as well as whatever experiences you might have had with this sort of thing.
The application consists of a server WAR and several rich-clients distributed in JARs. The trouble is that it's all in one big, hairy code base, one sourc...
How fanatic are you about elimination of duplicate code?
Personally, whenever I see duplicate code, either in testing code or production, I tend to refactor the duplication away. The only exception I make are these:
Sometimes the reduction in duplication is very minimal, because the newly refactored method have too many parameters to ...
Why should companies invest in refactoring components, though it is not going to add any new feature to the product ?
I agree it is to clean the code, fix bugs and remove dead code - but what is the take ??
...
Is there any way to use the VS2008 built-in Refactoring functionality on VB.NET projects?
...
Anyone knows a way to define refactoring in a more formal way?
UPDATE.
A refactoring is a pair R = (pre; T) where pre is the precondition that
the program must satisfy, and T is the program transformation.
...
Can anyone recommend a website, book, or simply a list of refactoring strategies for procedural languages as opposed to object oriented languages?
Everything I was able to find contained some strategies that could apply, most were useful only if working in an OO language.
...
Hi
My code works (yeah!) which sends json to a server.. would appreciate any thoughts on refactoring
1) My C# code sends this json to the server
{\"firstName\":\"Bill\",\"lastName\":\"Gates\",\"email\":\"[email protected]\",\"deviceUUID\":\"abcdefghijklmnopqrstuvwxyz\"}
Which I have to get rid of the slashes on the server side....not ...
I've been thinking lately, would it be a good form of syntactic sugar in languages like Java and C#, to include a "duck" type as a method parameter type? This would look as follows:
void myFunction(duck foo) {
foo.doStuff();
}
This could be syntactic sugar for invoking doStuff() via reflection, or it could be implemented different...
I have a solution that is missing a lot of code coverage. I need to refactor this code to decouple to begin to create unit tests. What is the best strategy? I am first thinking that I should push to decouple business logic from data access from businessobjects to first get some organization and then drill down from there. Since many ...