I am currently into the testing stage of a project I am working on and am having trouble bringing the main service under test in anything other than the most basic default test cases.
The Service is currently responsible for the creation of all sub-components, which I would like to change to use an IoC container.
What container should...
A discussion I had with a colleague today.
He claims whenever you use a 3rd party library, you should always write for it a wrapper. So you can always change things later and accomodate things for your specific use.
I disagree with the word always, the discussion arose regarding log4j and I claimed that log4j has well tested and time p...
Hi all,
I have a quick question about refactoring php code. Below are three functions. The first two appear quite similar, and only differ with one if statement. The third combines the first two through use of a flag. Is this the best practice? Here it seems okay to use a flag, but what if we need to add more flags in the future?...
When I rename a variable using ReSharper 4.5 (VS2008), the rename is performed inline (I specify the new variable name in the editor itself) or via a prompt (a popup window where I specify the new variable name).
I'm hoping someone can tell me what determines which approach is used?
...
We have a rather large codebase in C++ here that needs some refactoring; since it's generally bad to start from scratch, I was wondering if there were any good free code refactoring tools for Visual Studio 2005/Visual C++ 8.0?
...
Hi,
Wondering if someone can suggest a refactoring 'best practice' or more ideally a "check-list" that we can go through and refactor against common issues.
Some of these ideas were pretty good: http://my.safaribooksonline.com/9780321620293
But looking for more.
Thanks.
...
I'm trying to refactor an existing asp.net-mvc web application and introduce mvc-turbine.
The application works as is, but I want to make it more pluggable and maintainable so future maintenance will be easier.
I figured I'd try to keep the refactoring steps as small as possible, so I referenced MvcTurbine, MvcTurbine.Unity and MvcTurbi...
Background:
There are a few threads on SO about how to choose names for variables and functions. It dawned up on me that there might be a use for a site where you could go and ask random people what name a particular function should have. You describe the behavior, and they come up with a name. The benefit of this, you get multiple pers...
Hi all, I'm trying to write more readable and more efficient code, I've always hated if if if chains .. is it possible to write the following statement in some other more "elegant" way like maybe using ternary ops :
if(text.length < 1){
if(errtext.length > 1){
errtext+="<br>";
}
errors = true;
errtext += "Field cannot be emp...
I've got a bunch of functions that I want to move into a class. They're currently split into a couple of fairly long files. I'd prefer not to have one 2500 line file, but as far as I can tell, you can't use include to split a class up into multiple files. In theory, I could group the functions in different classes, but they're closely re...
I've been over to the site lately and nothing much seems to work (aside from the main page)
...
(Note: this is related to this question, but I think it could have been written more clearly, so I'm trying again -- my update only helped to a limited extent.)
I've inherited some code that creates a complex form with numerous sections, and lots of possible views, depending on a number of parameters. I've been working with it for a whi...
I'm about to embark on a bout of refactoring of some functions in my code. I have a nice amount of unit tests that will ensure I didn't break anything, but I'm not sure about the coverage they give me. Are there any tools that can analyze the code and see that the functionality remains the same?
I plan to refactor some rather isolated...
I have three database operations like so:
public void Add<T>(T entity)
{
using (var transaction = Session.BeginTransaction())
{
if (entity is IEnumerable)
{
foreach (var item in (IEnumerable) entity)
{
Session.Save(item);
}
}
else
{
...
I have an Event model with a finish_time field and a form checkbox called whenever. When whenever is checked I want to set finish_time to nil regardless of its value in parameters, when whenever is not checked I want to make sure that finish_time is a valid date before I save it in the database.
Currently I am achieving this using a w...
I am trying to refactor this code into a more elegant version. Can anyone please help.
The issue is where to as sign the first evaluation result for comparision later on?
And I want to eliminate the use of if/switch if possible
Should I remove Operator class and split Eval into And and Or class, but wouldn't be too much differnt I thi...
hi guys,
i needed help refactoring the following class,
Following is a class Operation with variety of Operations in switch :
i want to avoid the switch statement.I read few articles on using polymorphism and state pattern .but when i refactor the classes i dont get access to many variables,properties
Im confused on whether to use o...
I have solution A which defines public class Foo, and solution B which references A and uses Foo. I rename Foo to Bar in A and use the "Update References" feature, but that only updates the references in the current solution. How do I go about updating them in solution B as well (automatically)?
(note that search&replace isn't an option...
Hi there,
Currently I am exploring the world of ruby. Playing around in the irb you get nice intellisense for like 5.<tab><tab>. I tried many editors/IDEs (mainly gedit, vim, radrails) with a couple of plugins. I kind of do not like the bloated eclipse-style environment but as far as I fount out it is the only one providing intellisense...
I have a CUDA program that works fine, but that is currently all written in one file. I'd like to split this big file into several smaller ones, in order to make it easier to maintain and navigate.
The new structure is :
foo.cuh
foo.cu
bar.cuh
bar.cu
main.cu
The .cuh header files contain structs and function prototypes, and the .cu f...