» pages: blog | About Me | projects | Resume |

code style

code — davidb — January 31st, 2008

This quarter I started grading for a couple courses at RIT in the Computer Science Department. Coincidentally, I was also exposed to some of the ugliest code that I have ever seen in my life. The projects/labs that I grade are written in C/C++: two languages that make it easy to do the wrong thing (when you don’t know them). A combination of a lack of understanding of the language/syntax, a lack of exposure to proper style, and waiting until 11:59PM to submit what you’ve got before your midnight deadline has really broadened my horizon as to what bastardizations of style can occur. It really has taught me a lot. I already know the importance of comments, proper indentation, and producing readable, maintainable code, but nothing really reinforces that as much as if you were asked to analyze someone else’s poorly maintained code.

I’m almost done with my job as a grader for this quarter, so I feel like it’d be a good time to reflect a bit on what makes code good or bad. Good coding style means it is easily humanly readable, well documented/commented, and efficient. If you don’t know how to do something or know you’re having problems with a particular function/block of code, throw a comment in there to that effect and describe why it fails/is a hack/is iffy at best! It’s ok to leave debug code in, but surround it in #ifdef’s and document that as well – at the very least, note it as being for debug. You can take that a step farther by actually documenting what your debug code is doing. Sometimes, you just can’t get a solution (run out of time, bad day, too complicated of a scope, etc). That’s ok with me, but at least explain your thought process. Sometimes that’s interesting to see – maybe I can give you some points because you were on the right track but just don’t have enough exposure to the language. Take this for example (I did actually receive a submission quite similar to this):

 1 //getValues(**a, **b, &c); DIDN"T WORK!!!!
 2 //getValues(**a, *b, &c); DIDN"T WORK AGAIN!!!!
 3 //getValues(*a, *b, &c); BAHHHHHHHHH WHY>
 4 //getValues(a,b,c); i don’t get it. why god, why?
 5 //getValues(a,b,&c) JUST GIVE ME THE DAMN VALUES ALREADY!!!
 6 //giveUP() - sorry… please don’t take points off :) 
 7 //The use of this function doesn’t really have anything to do 
 8 //with the course material. This is just a stupid c function. 
 9 //I understand the course
10 //... [clip]

So, please, use good coding style for anything you do. Comment the heck out of your code. Another thing I highly suggest – actually look at the compiler’s output. It will save you a lot of headaches if you just suck it up and read it.

my new domain name

Uncategorized — davidb — January 31st, 2008

So, it’s about 4:00AM, I have a midterm in 6 hours, and I just finished setting up my domain. I had been meaning to buy one for a while now, but apparently David Brenner is a common name. Not only that, but I share my name with a semi-famous comedian. Notice the semi-famous part. He was voted #53 on Comedy Central’s Top 100 comedians, which apparently means approximately 1 out of every 100 or so people that read/hear my name decide to ask me, “Hey, are you related to that comedian?” and the other 99 have no idea that another David Brenner exists.

That said, I had the opportunity a few years ago to take davidbrenner.com, but I didn’t. What a shame. This is just about the only combination of my name available. I just found out it was available a few days ago, so I decided to go ahead and buy it. So, here it is.

(c) 2010 david-brenner.net | powered by WordPress with Barecity