I'm curious about how everyone handles code duplication across multiple platforms/tiers.
As an example, in our application we have a screen that displays claims.
A claim is deemed to be outstanding if it satisfies certain critera and users want to see which claims are outstanding in their lists, so there is one piece of code in the appl...
After I found out that there's no plugin for Simian in Maven 2, we turned to CPD, but it doesn't perform as well as Simian (observed in our Ant projects that use both Simian and CPD). I know that developers in my team have been checking in redundant code but CPD isn't flagging anything. I wanted to try out another code duplication analys...
I'm currently reviewing a very old C++ project and see lots of code duplication there.
For example, there is a class with 5 MFC message handlers each holding 10 identical lines of code. Or there is a 5-line snippet for a very specific string transformation every here and there. Reducing code duplication is not a problem in these cases a...
Hi!
Edit: I made a mistake in my original question. It should be about methods Last and LastOrDefault (or Single and SingleOrDefault, or First and FirstOrDefault - plenty of them!).
Inspired by this question, I opened Reflector and looked at code of
Enumerable.Last<T>(this collection)
Then I jumped to code of
Enumerable.LastOrDefau...
I've searched the Internet for a while now and I have not been able to find any free (or cheap) tools/utilities/modules that can analyze a set of Perl files (modules or scripts) and flag duplicate or cloned or copy/pasted code.
I'm better now, but I used to copy and paste sections of code all over the place. I'd like to clean it up and...
What tools can I use to find duplicate code that is a good candiate for refactoring?
Update:
Any language, any IDE.
...
Given this form (which contains a submit button):
<form id="review_form">
<input type="submit" id="btn_submit" value="Submit with ajax! (submit button)">
</form>
and this link (to submit the same form):
<a href="#" id="lnk_submit">Submit with ajax! (hyperlink)</a>
In the following jQuery code, when the #btn_submit element is clic...
In general I come across this a lot. Some of my co-workers prefer very simple, easy to read classes even if that means that there is some code duplication, whereas I do everything in my power to avoid code duplication, even if it means making more a complicated architecture. What is the best practice? I work exclusively in Java.
...
Hello,
I am developing a basic .html website using visual studio. I am wondering on how other people find this experience. I do not really want to replicate the navigation, header, footer code in each page so what do you use?
I was thinking I might have to use master pages and aspx, unfortunately masterpages and .html do not go. In d...
I want to automate moving duplicate or similar C code into functions.
This must work under Linux.
...
Hi all,
I am rephrasing this question to make it a little more straightforward and easy to understand, hopefully.
I have roughly 30 components (internal) that go into a single web application. That means 30 different projects with their own separate POM. I use inheritance quite a bit in my POMs so one of the things they inherit is a ...
I have multiple classes in a project that are exactly the same except for the name of the class. Basically, they represent glorified enums loaded at runtime from config files. The classes look like this:
public class ClassName : IEquatable<ClassName> {
public ClassName(string description) {
Description = description;
}
...
I have a need to restrict certain numbers to valid ranges in my application. I created delegates to handle this. I don't know if this is the right way to do it; I'm running into something that feels wrong.
public delegate int RestrictInteger(int minimum, int maximum, int value);
public delegate decimal RestrictDecimal(decimal minumum, d...
i have an asp.net mvc website where i build up most of the page using C# for example building up html tables given a set of data from my viewmodel
i also have a lot of javascript that then dynamcially modifies these tables (add row for example).
the javascript code to add a new row looks extremely similar to my "rendering" code i have ...
I don't know what this is called so I've struggled to find an answer from google but I have a vague memory of it from t'old days.
I've sub-classed (* see below) about 8 framework controls, overriden some properties and added some functionality into each one.
The changes I have made are identical in every case. If I make a change, I have...
I'm implementing a custom container with an STL-like interface. I have to provide a regular iterator and a const iterator. Most of the code for the two versions of the iterators is identical . How can I avoid this duplication?
For example, my container class is Foo, and I'm implementating FooIterator and FooConstIterator. Both of th...
Sadly, a project that I have been working on lately has a large amount of copy-and-paste code, even within single files. Are there any tools or techniques that can detect duplication or near-duplication within a single file? I have Beyond Compare 3 and it works well for comparing separate files, but I am at a loss for comparing single ...
I have several objects that look like this:
class PhoneNumber
{
String getNumber();
String getExtension();
DateTime getLastCalled();
}
class Address
{
String getCity();
string getState();
int getZip();
}
I'd like to be able to take a List of any one of those objects and get a list of a particular property. Th...
I have two snippets of code that tries to convert a float list to a Vector3 or Vector2 list. The idea is to take 2/3 elements at a time from the list and combine them as a vector. The end result is a sequence of vectors.
let rec vec3Seq floatList =
seq {
match floatList with
| x::y::z::tail -> yield V...
I wish to get a quick feeling for how much “copy and paste” coding we have, there are many tools for C# / Java to check for this type of thing. Are there any such tools that work well with VB.NET?
(I have seen what looks like lots of repeated code, but wish to get some number to help me make a case for sorting it out)
Update on prog...