What to do... Life's like that...

Sunday, June 04, 2006

Copy-Paste: A dichotomy in 21st century programming

A programmer in the 21st century is equipped with lots of tools and commands to expedite the process of software development. We even have good patterns for componentization and code reuse. But the one that stands out is the "physical" reuse of existing code using the Copy and the Paste commands. It comes in various forms like ctrl+c/ctrl+v, yy/p or ctrl+insert/shift+insert (for the purists) and is the most widely used tool I believe.

A question goes out to all the software programmers out there. When was the last time you sat down and wrote n (n > 10) lines of code thinking about each line you write, figuring out each and every parameter that goes into your API call, referring to documentation to make a judgement between the different types you can use based on their implementation and making full use of all the features your modern programming language provides? The answer could date back to your school days, probably when you wrote your first "hello world" program (hmm... I visually copied it from K&R :)). With hard deadlines and high pressure work environments meticulous programmers could be an endangered species. But is this good or bad?

The good part is that it saves a lot of time and effort, an otherwise monotonous job for the programmer. Also, there could be reduction in the errors as the source for most of this code would be either well written samples or code that has already been reviewed and tested for quality (assuming samples are well written and written code is tested properly, could be disastrous otherwise :)). Unless the applications are super-critical, a certain degree of slack doesn't cause any harm especially if they are bound to save time.

The bad part however is the lack of depth. We take things for granted without understanding the details, which could be very detrimental. We forget the specifics and could lose out in the long term. What is specific today could become fundamental tomorrow. We may even ignore some of the facilities provided by a programming language thus bringing down the utility of the language. I've run into a lot of examples and also have heard a lot about this problem from my colleagues and friends.

A good practice would be to reuse code but to understand thoroughly what it is supposed to do and why it is coded in that way. Let the 2 finger exercise continue, but the content on the clipboard must never be ignored. Ignorance may not be blissful always :-).
share this: facebook

1 Comments:

At August 15, 2006 4:23 PM, Blogger Komal said...

I guess it depends a lot on what one is working on.

If one is doing a lot of copy, paste, perhaps, once should think of putting it in a common library.

I work in C# and think lot of day-to-day code is already available in libraries and the rest gotta be different. if there's lot of overlaps, a library or something common should be a solution.

 

Post a Comment

<< Home