I am trying to discover how great our problem is with duplicate code, therefore I need to be able to mail a nice report (HTML, PDF, or word) to everyone on the team that lists all the duplicates that are found.
How do I create such a report? (At this stage, I am just looking for a one-of ad hock solution to help with scoping the proble...
In a recent code review I spotted a few lines of duplicated logic in a class (less than 15 lines). When I suggested that the author refactor the code, he argued that the code is simpler to understand that way. After reading the code again, I have to agree extracting the duplicated logic would hurt readability a little.
I know DRY is gu...
class A extends ApiClass
{
public void duplicateMethod()
{
}
}
class B extends AnotherApiClass
{
public void duplicateMethod()
{
}
}
I have two classes which extend different api classes. The two class has some duplicate
methods(same method repeated in both class) and how to remove this duplication?
Edit
Both ...
Hi!
I'm looking for a simplest way to remove duplication in my WPF code.
Code below is a simple traffic light with 3 lights - Red, Amber, Green. It is bound to a ViewModel that has one enum property State taking one of those 3 values.
Code declaring 3 ellipses is very duplicative. Now I want to add animation so that each light fades i...
If multiple teams write Silverlight applications that access the same DB, there will be duplication between the generated services. Also, if developers customize the service with BL this is another duplication. Isn't it be better to expose a single reusable data service for the whole organization to share?
Yes, it was possible to write ...
i have a method that looks like this:
private double GetX()
{
if (Servings.Count > 0)
{
return Servings[0].X;
}
if (!string.IsNullOrEmpty(Description))
{
FoodDescriptionParser parser = new FoodDescriptionParser();
return parser.Parse(Description).X;
...
Code
The following code calculates the slope and intercept for a linear regression against a slathering of data. It then applies the equation y = mx + b against the same result set to calculate the value of the regression line for each row.
How can the two queries be joined so that the data and its slope/intercept are calculated withou...
Are there any tools available that can scan multiple .php files and report back duplicated lines/chunks of code?
It doesn't have to be really smart but basically give me a starting point for manual scans to improve the codebase of some of my apps.
...
I have the following (Python) code to check if there are any rows or columns that contain the same value:
# Test rows ->
# Check each row for a win
for i in range(self.height): # For each row ...
firstValue = None # Initialize first value placeholder
...
How do I refactor to remove the code duplication in this spec:
describe 'TestPlugins'
describe '.MovieScanner(document)'
before_each
MoviePage_loggedIn = fixture("movie_logged_in.html") // Get logged-in movie page
MoviePage_notloggedIn = fixture("movie_not_logged_in.html") // Get no...
i have the following code which has some duplication
private List<SelectListItem> GetDeskList(int deskId)
{
List<Desk> apps = Model.GetDesks();
List<SelectListItem> dropdown = apps.ConvertAll(c => new SelectListItem
{
Selected = c.Id == deskId,
Text = c.Name,
Value = c...
I have a C# project which has many web references to a third party product. All of these web service calls use a 'user context' class. So each web service accepts the exact same XML snippet.
Currently I have to keep many of these 'user context' objects around as I hit all the different web service calls. The generated 'user context' cla...
hi,
i am using get and setters in my as3 code to edit values of an other class (because those variables are shared) i dont like to put stage.sharedVar.isScrabble in my code every time to change a variable so i used get/set functions
see below
private function get isScrabble(){return stage.sharedVar.isScrabble;}
private function set i...
At which point do you decide that some of your subroutines and common code should be placed in a class library or DLL? In one of my applications, I would like to share some of my common code between different projects (as we all know, it's a programming sin to duplicate code).
The vast majority of my code is all within a single project....
I need to loop through a number (xx). xx always starts at zero. My problem is that if the moveDirection variable is +1 then xx increases until it reaches the positive of range. If moveDirection is -1, then xx decreases until reaching the negative of range.
In the code below, I have done this by having an if statement test for moveDirect...
I'm new to JSF and am wondering if I got things right. Let's say I have a simple CMS that makes it possible to write pages.
First, I define a JPA entity called Page:
@Entity
public class Page {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column
private Long id;
@Column private String title;
@Column private Strin...
What is the most appropriate sentinel method?
This breaks out of an infinite loop:
infinite loop
read in a value;
if (value == Sentinel) then exit;
process the value;
This uses duplicate code:
read in a value;
while (value != Sentinel)
process the value;
read in a value;
This uses a boolean variable i...
I have a table Inputs and a derived table Parameters
CREATE TABLE Configurables
(
id SERIAL PRIMARY KEY
);
CREATE TABLE Inputs
(
configurable integer REFERENCES Configurables( id ),
name text,
time timestamp,
PRIMARY KEY( configurable, name, time )
);
CREATE TABLE Parameters
(
configurable integer,
name text,
time time...
Clone Detective was a great tool for finding duplicate code in VS 2008.
Are there any tools for finding duplicate code which integrate into VS 2010?
*Clone Detective doesn't look like its being actively developed 1 2.
...
I have a lot of code like this:
#define WITH_FEATURE_X
struct A {
#ifdef WITH_FEATURE_X
// ... declare some variables Y
#endif
void f ();
};
void A::f () {
// ... do something
#ifdef WITH_FEATURE_X
// ... do something and use Y
#else
// ... do something else
#endif
// ... do something
}
and I'd like to replace the #defin...