ANTIPATTERN – Cut and Paste Programming

I love reading computer manuals, be they about software architecture, algorithmic, programming, security, cloud storage and operations, big data, machine learning or others.
The following text is taken from the book “AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis

Also Known As:
Clipboard Coding, Software Cloning, Software Propagation
Root Causes
: Sloth

Cut-and-Paste Programming is a very common, but degenerate form of software reuse which creates maintenance nightmares. It comes from the notion that it’s easier to modify existing software than program from scratch. This is usually true and represents good software instincts. However, the technique can be easily over used.

This AntiPattern is identified by the presence of several similar segments of code interspersed throughout the software project. Usually, the project contains many programmers who are learning how to develop software by following the examples of more experiences developers. However, they are learning by modifying code that has been proven to work in similar situations, and potentially customizing it to support new data types or slightly customized behavior.
This creates code duplication, which may have positive short-term consequences such as boosting line count metrics, which may be used in performance evaluations.

– The same software bugs reoccurs throughout software despite many local fixes.
– Lines of code increase without adding to overall productivity.
– Code reviews and inspections are needlessly extended.
– It becomes difficult to locate and fix all instances of a particular mistake.
– Code is considered self-documenting.
– This AntiPattern leads to excessive software maintenance costs.
– Developers create multiple unique fixes for bugs with no method of resolving the variations into a standard fix,
– Cut-and-Paste Programming form of reuse deceptively inflates the number of lines of code developed without the expected reduction in maintenance costs associated with other forms of reuse.

– It takes a great deal of effort to create reusable code, and organization emphasized short-term payoff more than long-term investment.
– The context or intent behind a software module is not preserved along with the code.
– The organization does not advocate or reward reusable components, and development speed overshadows all other evaluation factors.
– There is a lack of abstraction among developers, often accompanied by a poor understanding of inheritance, composition, and other development strategies.
– The organization insists that code must be a perfect match to the new task to allow it to be reused. Code is duplicated to address perceived inadequacies in meeting what is thought to be a unique problem set.
– Reusable components, once created, are not sufficiently documented or made readily available to developers.
– A “not-invented-here” syndrome is in operation in the development environment.
– There is a lack of forethought or forward thinking among the development teams.
– Cut-and-Paste AntiPattern is likely to occur when people are unfamiliar with new technology or tools; as a result, they take a working example and modify it, adapting it to their specific needs.

TheCut-and-Paste Programming AntiPattern is acceptable when the sole aim is to get the code our of the door as quickly as possible. However, the price paid is one of increased maintenance.

Read more on topic in the book from here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: