05.12.07
I don’t update my blog
Get used to it
Everything related to progamming with a focus on more advanced topics
For some reason the navigation bar doesn’t show up correctly in firefox. For the z800track page, click here: z800track page
Here’s a link to a very good comment by Len Holgate on why so much code sucks. I agree fully….
I’ve started to upload some small libaries and utilities that I’ve written over the years. Most of these have been extremely usedful for me, and may be for someone else as well. I’ve also got more on the way, including a LALR parser generator for Windows that makes yacc/lexx look like a Ford Model-T(in the old sense, not the classic sense
, A tiny backpropagation neural-network, a tiny HTTP server library, and my favorite; A windows-based high-performance server library written in c. I have to admit, I started out using Len Holgate’s SocketServer library, but became disillusioned at the sheer OO of it. Although it’s a shining example of well-designed code, I think it’s just a little over-the-top as far as C++ goes. Which brings me to my next point. All of the source code I post on this site is in C. Let me explain. I know C++ very well, having used it exclusively over the past 10 years, but it seemed that as time progressed, and programmers became more awair of overrides and polymorphism, things started to get out of hand. I’ve trudged through code with over 5 levels of inheritance. That was just too much for me. It gets to a point where the drawbacks of a language feature far outweigh the benefits(and likely the language designer’s intent). So, I had an emotional backlash recently, and decided to go back to C with all it’s callback functions, casting, and homegrown inheritance. I feel that one or two levels of inheritance is all that’s needed. So did Java’s designers. If you can’t get it done within that level, re-think your class layout. I’ve also spent several years doing embedded development, where C++ wasn’t always available, so any libraries I wrote at the time would have been in C so that I could share them among projects. And finally, it’s always easy to wrap C with C++ rather than vice-versa.
When it comes to commenting of source code, most people have a fairly strong stance. Some people think that they are a must, and every line should be commented. Others think that they are a waste of time and that they don’t help. I’m somewhere in between. I’ve sat through code reviews with one guy constantly piping up with “we should see more comments here”, and the person who wrote the code giving a “o.k, sure” out of the side of his mouth while plotting the “accidental death” of the reviewer. I’ve also seen code that did an entire functional process that had no comments whatsoever, and I had to make changes. I only want to see comments on code that is functionally complex enough that it can’t be understood with more than a cursory glance. I don’t ever want to see comments like this(this is a filler comment):
/* add one to asdf */
asdf = asdf + 1;
This is a completely useless comment. Anyone who can’t figure out what that statement does has no business reviewing the code. However, this sort of comment(which I call a functional comment), is useful:
/* the index needs to be incremented so we don’t overwrite the last entry */
asdf = asdf + 1;
There is a big difference between a filler comment and a functional comment. A functional comment will actually help the reviewer understand the logic of why things are done this way. But, I don’t really care about how the reviewer understands my code. It’s really more selfish than that. My main reason for writing comments like this is that it helps to solidify my developing logic process as I write the code. It’s like positive reinforcement for logic development. As I think about the logic I’m trying to accomplish, and I write a line of code and add the comment, it’s now down on paper. This has 2 benefits. First, it will “breadcrumb” the throught process so I can get back to where I was if an interruption(such as having to leave work) occurs. Second, it solidifies my thought process, so that I can develop it further. Some people, like Len Holgate, say they hate comments because the comments get out of date and become useless. I agree, but I think it’s a cardinal sin to change code without updating the comments as well, so this scenario shouldn’t happen. I would much rather see comments designed with the same care as the code itself, and in that case, comments are indispensable.
Welcome to my coding blog. This site was created to share ideas about coding. I’ve been coding for about 20 years now, through many different languages and trends, and am currently a little disappointed in the state of affairs. It’s not that I don’t think current generation programming languages are sufficiently evolved or capable, but it’s just that I don’t like most source code that I look at. 99% of source code that I see looks as if the programmer spent about 10% of their brainpower on it. It seems that WAY too much proof-of-concept code actually makes it through to production. It really bothers me that most programmers don’t want to create the absolute best code that they are capable of. I also think that there is a large disparity between research programmers and production programmers. The research guys come up with some cool algorithms, but it seems that their examples and source are always unusable because they don’t know how to make it look good or work well. How many times have you tried to use a program for some purpose, only to find that it’s hacked together and doesn’t work well. But if it’s not open-source, you’d have to spend waaaay too much time doing it better. My goal of this blog is to post some of the work I’ve done as I’ve evolved as a programmer, and let others peruse it and use it for their own purpose. I’m not claiming that it’s all a shining example of good programming. Some of it just plain sucks. But it’s a start.