<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>david-brenner.net &#187; code</title>
	<atom:link href="http://www.david-brenner.net/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.david-brenner.net</link>
	<description></description>
	<lastBuildDate>Tue, 08 Dec 2009 13:32:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0-beta1</generator>
		<item>
		<title>code style</title>
		<link>http://www.david-brenner.net/2008/01/code-style/</link>
		<comments>http://www.david-brenner.net/2008/01/code-style/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 02:24:48 +0000</pubDate>
		<dc:creator>davidb</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://localhost/blog/?p=6</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>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&#8217;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&#8217;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&#8217;s poorly maintained code.</p>
<p>I&#8217;m almost done with my job as a grader for this quarter, so I feel like it&#8217;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&#8217;t know how to do something or know you&#8217;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&#8217;s ok to leave debug code in, but surround it in #ifdef&#8217;s and document that as well &#8211; 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&#8217;t get a solution (run out of time, bad day, too complicated of a scope, etc). That&#8217;s ok with me, but at least explain your thought process. Sometimes that&#8217;s interesting to see &#8211; maybe I can give you some points because you were on the right track but just don&#8217;t have enough exposure to the language. Take this for example (I did actually receive a submission quite similar to this):</p>
<pre>
<span class="lnr"> 1 </span><span class="Comment">//getValues(**a, **b, &amp;c); DIDN&quot;T WORK!!!!</span>
<span class="lnr"> 2 </span><span class="Comment">//getValues(**a, *b, &amp;c); DIDN&quot;T WORK AGAIN!!!!</span>
<span class="lnr"> 3 </span><span class="Comment">//getValues(*a, *b, &amp;c); BAHHHHHHHHH WHY&gt;</span>
<span class="lnr"> 4 </span><span class="Comment">//getValues(a,b,c); i don’t get it. why god, why?</span>
<span class="lnr"> 5 </span><span class="Comment">//getValues(a,b,&amp;c) JUST GIVE ME THE DAMN VALUES ALREADY!!!</span>
<span class="lnr"> 6 </span><span class="Comment">//giveUP() - sorry… please don’t take points off :) </span>
<span class="lnr"> 7 </span><span class="Comment">//The use of this function doesn’t really have anything to do </span>
<span class="lnr"> 8 </span><span class="Comment">//with the course material. This is just a stupid c function. </span>
<span class="lnr"> 9 </span><span class="Comment">//I understand the course</span>
<span class="lnr">10 </span><span class="Comment">//... [clip]</span>
</pre>
<p>So, please, use good coding style for anything you do. Comment the heck out of your code. Another thing I highly suggest &#8211; actually look at the compiler&#8217;s output. It will save you a lot of headaches if you just suck it up and read it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.david-brenner.net/2008/01/code-style/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
