Hi there,
I have a piece of code where in there are 2 overloads which differ by data types of parameter and have different number of parameters as well. I am looking to reduce the code duplication. What are the possible ways I can do this?
My code looks like this:
public void publicMethod(double[,] data, double increment)
{
...
I have a C# .NET 2.0 script and I want to know why the following code would be faster than a do while loop of the same kind.
private double getStop(double avgPrice, bool longTrading)
{
double stopS = 0.0;
double stopL = 0.0;
for (int i = 0; i < 13; i++)
{
if (i == 0 || i == 12)
{
stopS = 0.0;
stopL = 0.0;
}
...
I am using Resharper 4.5 in Visual Studio 2008. Whenever I try to extract a block of code into a method, it tries to create a subroutine and not a function. The return type option is disabled. Does anyone have any advice as to how I can get it to create a function and not a subroutine?
thanks!
...
This is the scenario: I have a huge code-base written in .NET 2.0...and sometime back the migration happened to .NET 3.5.
This code-base is both refactored and enhanced as an ongoing maintenance project. I am looking for patterns to identify in code base which are good candidates for LINQ to Objects.
I need pointers for comprehensive a...
Hi guys,
Please take a look at this piece of code I came up with.
abstract class Command
{
public void Execute(string[] commandParameters)
{
CommandResult result = ExecuteCommand(commandParameters);
PrintResult(result);
}
public abstract CommandResult ExecuteCommand(string[] commandParameters...
hi,
I found a very tempting function in Netbeans, which is to re-factor or 'beautiful-ize' the c++ code according to some parameters, such as tab length, {'s position, etc
is there anything similar in Eclipse, which keyword should I google?
...
The purpose of the code below is to determine if a particular date qualifies as a "weekend" i.e after 12:00 PM on Thursday, minimum 2 days and before Monday 12:00 PM
Is there a better way? If-Else turns ugly and the Strategy pattern is way too much work for this.
public bool ValidateWeekend(DateTime pickupDate, DateTime dropoffDate)
...
Have you used JustCode? is it better than resharper? seems like performance better. Do I need to uninstall resharper before using JustCode?
...
I have some code that I had to write to replace a function that was literally used thousands of times. The problem with the function was that return a pointer to a static allocated buffer and was ridiculously problematic. I was finally able to prove that intermittent high load errors were caused by the bad practice.
The function I wa...
I'm looking for a diff tool that will allow me to compare just a sub-section of a file with a section of another file, or even of itself. Preferably eclipse based but will take all suggestions.
Yes I know I can copy out the two sections into different files and compare those, but that is very tedious when you are trying to do a large am...
I have a question about simplifying some Collection handling code, when using Google Collections.
I've got a bunch of "Computer" objects, and I want to end up with a Collection of their "resource id"s. This is done like so:
Collection<Computer> matchingComputers = findComputers();
Collection<String> resourceIds =
Lists.newArrayLi...
I'm using Eclipse 3.something and would like to know if it is possible to create a new method from selecting a block of code? Obviously the method's signature would contain the necessary existing references and we can't return more than one variable from a method.
I have various methods where code related to presentation is mixed with ...
Every now and again, I make use of the Eclipse refactoring feature. Some techniques are more obvious then others and some I never tried.
What refactoring is most useful for you and why?
Note: I find this presentation very useful, perhaps because it is example driven therefore easy to understand:
"Refactoring for everyone - How and why...
Tools like CodeRush and Resharper offer lots of simple refactorings, such as 'Rename Variable'. But if you could have any refactoring feature at all (no matter how complex), what would it be?
(I know, everyone wants a 'make program perfect' refactoring, but let's be realistic here.)
...
I am trying to refactor a class I have into 2 classes. Unfortunately eclipse's extract class function seems to only support the variables which really isn't all that helpful. Is there a way to do it that extracts the methods or Is there a plugin that does it? Thanks
...
At my workplace we're planning a major refactor on our core product, a web application with several 'modules'. I quoted that because that's one of our main concerns: modules are not really modules, the whole thing is monolithic. The application is written in PHP with smarty templating and using Pear for accessing a MySQL database. We're ...
We have a project with around 500,000 lines of code, managed with git, much of it several years old. We're about to make a series of modifications to bring the older code into conformance with the developer community's current standards and best practices, with regards to naming conventions, exception handling, indentation, and so forth...
I might inherit a somewhat complex multithreaded application, which currently has several files with 2+k loc, lots of global variables accessed from everywhere and other practices that I would consider quite smelly.
Before I start adding new features with the current patterns, I'd like to try and see if I can make the basic architecture...
I have written the following code in my Rails app to generate XML. I am using Aptana IDE to do Rails development and the IDE shows a warning that the code structure is identical in both the blocks. What changes can be done to the code to remove the duplicity in structure? Is there any other way to write the same?
xml.roles do
@roles...
I'm writing a simple little ocaml program that reads an algebraic statement in from a file, parses it into an AST using ocamllex/ocamlyacc, reduces it, and then prints it. The part where I'm reducing the expression seems a bit... ugly. Is there any way I can simplify it?
(* ocaml doesn't seem to be able to take arithmetic operators
a...