Comments on: Types of Duplication in Code https://simpleprogrammer.com/types-of-duplication-in-code/ Tue, 11 Dec 2018 21:05:38 +0000 hourly 1 https://wordpress.org/?v=7.0 By: Combating code duplication to reduce software maintenance cost – Optivem https://simpleprogrammer.com/types-of-duplication-in-code/#comment-728 Tue, 11 Dec 2018 21:05:38 +0000 https://simpleprogrammer.com/?p=1539#comment-728 […] Types of Duplication in Code (Simple Programmer) […]

]]>
By: Dale Vivian Ross https://simpleprogrammer.com/types-of-duplication-in-code/#comment-727 Fri, 30 Jan 2015 16:24:00 +0000 https://simpleprogrammer.com/?p=1539#comment-727 I’m hoping to be able to identify some of that in my code while also learning about laravel in an application I wrote a few years ago. Someone (you) recommended that I record it so let’s see how that turns out :). http://coderoom.dajengroup.com/2015/01/29/cleaner-code-lighter-load/

]]>
By: Dale Vivian Ross https://simpleprogrammer.com/types-of-duplication-in-code/#comment-726 Fri, 30 Jan 2015 16:19:00 +0000 https://simpleprogrammer.com/?p=1539#comment-726 In reply to franjobrekalo.

I suspect you could have an action that does nothing in the case where the logic isn’t required. I’m not sure that is the most efficient solution though.

]]>
By: Mark Miller https://simpleprogrammer.com/types-of-duplication-in-code/#comment-725 Tue, 29 May 2012 17:30:56 +0000 https://simpleprogrammer.com/?p=1539#comment-725 Hi John, great article. I’m wary of the naming chosen for the different types of duplication. In this article, the first part of the name identifies the piece that *differs* and the second part of the name is “duplication”. So when the data differs, it’s called “data duplication”, two words together that mean the *opposite* of what is really happening. I’m hopeful we can come up with better ways to identify what is changing while still keeping the names for these three kinds of duplication easy to use and meaningful.

]]>
By: jsonmez https://simpleprogrammer.com/types-of-duplication-in-code/#comment-724 Tue, 29 May 2012 17:16:44 +0000 https://simpleprogrammer.com/?p=1539#comment-724 In reply to Shashi.

Yes, you are correct. Was just trying to keep to super simple, but in a real world application, you are absolutely right.

]]>
By: Robert Stackhouse (@rstackhouse) https://simpleprogrammer.com/types-of-duplication-in-code/#comment-723 Tue, 29 May 2012 15:38:15 +0000 https://simpleprogrammer.com/?p=1539#comment-723 Thanks for sharing. I appreciate the fact that with delegates in C# we can make functions (almost) first class citizens.

To me, the “Algorithm Duplication” term is the most clear. It says, “You are doing these things in this sequence in multiple places with a slight variation. That variation being what method gets called in the middle.”

In all the cases, what is duplicated is the generic rather than the specific.

The terms “Type Duplication” and “Data Duplication” seem misleading.

Type Duplication would indicate to me that you’ve got two classes that do the same thing. “Overload Duplication” might be a better appointed term here.

Data Duplication, to me, would indicate that you have the exact same data (possibly in the exact same format) in different stores. I’ve primarily been a web developer in my career. Therefore, I naturally think of data in the same terms the pointed haired bosses do: the stuff that lives in the RDBMS. To me, “Method Call Duplication” would be clearer here.

My $0.02.

]]>
By: Shashi https://simpleprogrammer.com/types-of-duplication-in-code/#comment-722 Tue, 29 May 2012 13:46:36 +0000 https://simpleprogrammer.com/?p=1539#comment-722 John,

The type refactoring example you’ve shown needs to be made safer by using constraints. The problem with the way the method looks now is that in assumes container.Get() can support any type T. This means we’ve changed the specification of the method and introduced bugs.

]]>
By: jsonmez https://simpleprogrammer.com/types-of-duplication-in-code/#comment-721 Mon, 28 May 2012 15:08:36 +0000 https://simpleprogrammer.com/?p=1539#comment-721 In reply to Sean Feldman.

I agree with you on that, although there are often ways to do both by moving your common methods into a framework.

]]>
By: Sean Feldman https://simpleprogrammer.com/types-of-duplication-in-code/#comment-720 Mon, 28 May 2012 12:07:22 +0000 https://simpleprogrammer.com/?p=1539#comment-720 John,
Good post. I used to think that duplication is evil. Certainly duplication is code. Yet there are casing when you want to break down your logic in simple chunks and duplication is intended for the purpose of breaking down system into components. As an example – services. I’d rather have independent services that can be managed separately, then no duplicated code at all and need to touch every service that shares code when one of them is updated.

]]>
By: franjobrekalo https://simpleprogrammer.com/types-of-duplication-in-code/#comment-719 Mon, 28 May 2012 05:17:38 +0000 https://simpleprogrammer.com/?p=1539#comment-719 For me the hardest part is when some of the logic is repeated and not all of them. So, I have several functions and some of them repeat some logic, but not all of the functions repeats all logic. I’ve found it easier to just let it be the way it is, but the problem had come, when I had to make changes – I was changing each function, of course. If my code was in one place, then only that function needed to be changed.

Very well written – I’ve never thought before about algorithm duplication and – of course – mostly I don’t use delegates in my programmming.

]]>