News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

John Sonmez's Blog:
Types of Duplication in Code
May 29, 2012 @ 13:58:03

On his "Simple Programmer" blog John Sonmez has a new post looking at three kinds of "code duplication" that you should keep an eye out for when coding your applications:

One of the biggest reasons to refactor code is to eliminate duplication. It is pretty easy to introduce duplication in our code either unintentionally or because we don't know how to prevent or get rid of it. [...] I've found that there are three basic types of duplication that we can eliminate from our code that successfully build on each other.

He describes the three types - data, type and algorithm - and gives some code snippets showing how they present themselves and simple solutions of how to resolve them. There's also a quick mention of a "combined attack" when more than one form of duplication shows up at once. He suggests a to help find the "edges" of the duplication:

I've also found the key to eliminating duplication is sometimes to first exaggerate it. Often I will purposely take two methods that I know have some duplication and make them look even more duplicated in order to be able to clearly see where the duplication lies.
0 comments voice your opinion now!
code duplication data type algorithm


blog comments powered by Disqus

Similar Posts

Brian Swan's Blog: Consuming "Dallas" Data with PHP

Zend Developer Zone: Accessing DB2 Data Inside of i5/OS

PHPMaster.com: PHP Security: Cross-Site Scripting Attacks (XSS)

Daniel Krook\'s Blog: Public draft - Developing PHP Applications for IBM Data Servers

PHPMaster.com: Data Structures for PHP Devs: Stacks and Queues


Community Events





Don't see your event here?
Let us know!


composer language introduction voicesoftheelephpant mvc symfony series podcast opinion package release security interview library update community laravel version tool framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework