* Posts by Mark D Jones

1 post • joined 4 Dec 2007

Code scavenging goes formal

Mark D Jones

Copy and paste not as good as a good code library

The problem with a lot of code use is that it promotes BAD programming. I copy it from here, and paste it in this program and that program and that program and pretty soon I have lots of code that does the same thing being maintained in 20 different places.

Code Libraries are far better than this cut and paste mentality. The C Runtime Library made things easy to port, easy to use and in general help progress the art of computer programming way more than this arbitrary scrapbook of code you can paste from.

.NET and Java have almost gone too far the other direction with such a thick book of code that you don't have to invent much to do simple things (image manip, crypto, ....) but you need an encyclopedic brain to remember which package it is in.

We use a few core libraries in our development work and when we add functionality to one app that might be useful in the other, we put it in one of those core libraries:

WinExtensions - Thing Win32 should have had but didn't get

ImageCore - Things to do with Imaging

Generic - Things that STL didn't include

Boost - Nuff said

XMLib - XML stuff that sits on top of xerces (convenience mostly)

By collecting our code into groups like this we don't need so much to copy and paste and we maintain the code (with unit tests) in ONE spot.

I think it would be better to work on taming the Java and .NET API beast (although that might not be possible) than trying to make a cut and paste beast like this would become.

Design Patterns..... Yea, that's it!