The Art of Programming

An important part of programming is, of course, making a program that does what it’s supposed to do. In other words, it should have no bugs. You know all this. However, focusing on correctness, on bug-free programs, misses a lot of what programming is all about. Programming is not just about the end product; it’s about the process that gets you there. (Anyway, an ugly process will result in buggy code. This happens every time.)

Programs aren’t just built in one go, like a bridge. They are talked about, sketched out, prototyped, played with, refactored, tuned, tested, tweaked, deleted, rewritten….

A program is not built; it is grown.

Because a program is always growing and always changing, it must be written with change in mind. I know it’s not really clear yet what this means in practical terms, but I’ll be bringing it up throughout the book.

Probably the first, most basic rule of good programming is to avoid duplication of code at all costs. This is sometimes called the DRY rule: Don’t Repeat Yourself.

I usually think of it in another way: a good programmer cultivates the virtue of laziness. (But not just any laziness. You must be aggressively, proactively lazy!) Save yourself work whenever possible. If making a few changes now means you’ll be able to save yourself more work later, do it! Make your program a place where you can do the absolute minimum amount of work to get the job done. Not only is programming this way much more interesting (it’s very boring to do the same thing over and over and over…), but it produces less buggy code, and it produces it faster. It’s a win-win-win situation.

Either way you look at it (DRY or laziness), the idea is the same: make your programs flexible. When change comes (and it always does), you’ll have a much easier time changing with it.

Well, that about wraps it up. Looking at other technical books I own, they always seem to have a section here about “Who should read this book” or “How to read this book” or something. Well…I think you should read it, and front-to-back always works for me. (I mean, I did put the chapters in this order for a reason, you know.) Anyway, I never read that crap, so let’s program!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.225.220