code-duplication

How do I get Simian to produce a nice HTML report I can email to everyone on the team?

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...

How much duplicated code do you tolerate?

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...

remove duplicate code in java

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 ...

How to parametrize WPF Style?

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...

Are WCF RIA services a good thing?

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 ...

is there a way to remove duplication in this code

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; ...

Remove redundant SQL code

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...

A tool for finding duplicate code in PHP

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. ...

Operating on rows and then on columns of a matrix produces code duplication

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 ...

BDD / TDD with JSpec - Removing code duplication

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...

How can this code be cleaned up to remove duplication ?

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...

Many WebReferences Using Same Class

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...

Flash, ActionScript 3: using get/set properties to get values from other classes creates much duplicate code can it different?`

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...

How to Decide when to Implement a DLL?

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....

How to reduce code duplication in this example

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...

how to avoid model code duplication with JSF and JPA

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?

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...

How to solve code duplication in the following PostgreSQL query?

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...

Detect duplicate code in Visual Studio 2010

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. ...

template parameters, #define and code duplication

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...