Thursday, March 09, 2006

CODING TENET: Don't be clever

CODING TENET: Don't be clever unless you have to be.

By clever here I mean "code that is hard to understand at first glance". Such code is harder and more costly to maintain, so think long and hard about when you want to put forth that kind of effort in the future before you insert your whiz bang implementation of string searching.

I've met plenty of developers who think it is great to make brain-damaging clever optimazations of code where it makes absolutely no difference. For example, lets say we updating the GUI of our application. From a programmer's perspective, the GUI is INCREDIBILY slow. Humans can't see much below 30 frames a second, which means that, in terms of your interface taking 1 millisecond or 300 millisecond LOOKS EXACTLY THE SAME to the user. I'll repeat my point: Don't be clever when you don't have to be.

The same holds true for all those really fancy algorithms you learns about in CS. The reality is that for small numbers of elements (in the hundreds lets say), doing the brain dead stupid bubble sort or linear search is just fine. Sure it is O(N^2), but the user can't tell. Don't be clever when you don't have to be.

Wednesday, March 08, 2006

Good vs. Great Developers: Part 1

I'm a firm believer in the theory that "cargo cult programming" is the surest path to worthless software. We've all seen the following:

//I have no idea why, but the next line is required to make such and such work
<some code line that makes no sense>

Comments like this are a clear sign that you are cargo cult programming. If you ever find yourself writing this comment, STOP! Really, you will thank me later. Figure out why this is needed (or at least put up a reasonable guess). The "I have no idea" comment means that you are too lazy to care about what this line of code is accomplishing. That sets a poor precident about your ambition, skills, and re-enforces a poor habit.

Don't copy code you don't understand. Great programmers started as horrible programmers just like everyone else. The difference is drive. The drive to improve is what makes them great. I've never met a great developer who was happy with the code they wrote last year. They are always embarassed by that code, because they have learned more in the mean time.

The difference between great programmers and just good programmers is that great programmers try to understand everything about everything that matters (see below), not just their code. They understand their code, the code of the framework they execute in, the overarcing design, the minute design of each interface, and everything in between. They are the people who actually pay attention in code reviews and give you back useful comments about both high level API design and the fact that you are calling function X with a one-off parameter error.

In short, they are the people you want on your team.

Tuesday, March 07, 2006

Hello World

Coding from the Midwest is my blog for anything programming related that I find that I would like to archive to a common web address. This site is going to include links, how-tos, articles, code snippets, and whatever else I feel like keeping around in a permanent manner.

Ok, so you might have noticed on the right side of this blog that I am currently living in Alabama, which is unversially decried as not midwest. My living is here is now a temporary state. Hence, the title of this blog is all about forward thinking in the design phase:)

About Me: (I know no one cares, but hey, posts like this are as required as the ubiquitous "Hello World!" programs) I've been coding computers since I was 12 or so (~1990). I started on an original IBM PC and taught myself to code BASIC via a computer printout of the source to my grandfather's custom business tracking software.

I received my BS in Computer Science from Michigan State University in 2000. I've written major applications in C++, Visual Basic 6.0, and C# and I have written code for devices ranging from embedded systems to 32-way servers. Recently, I have focused heavily on .NET development. Don't be surprised if this blog is really a .NET blog in the future.