<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5544444055644552303</id><updated>2012-01-26T10:43:21.767-08:00</updated><title type='text'>Don't Cuddle Your Braces</title><subtitle type='html'>&lt;a href="http://cuddleyourbraces.blogspot.com"&gt;vs. The One Terrible Bracing Style (TBS)&lt;/a&gt;&lt;br/&gt;
A record of rants about software engineering.&lt;br/&gt;
Somewhere to air out the minutiae.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dontcuddleyourbraces.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://dontcuddleyourbraces.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>schwerwolf</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5544444055644552303.post-8002672156854202933</id><published>2008-04-30T06:23:00.001-07:00</published><updated>2008-04-30T06:40:32.118-07:00</updated><title type='text'>Ternary operator considered harmful</title><content type='html'>The distinct syntax of the ternary operator confused me until I read about it in a book.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;(predicate) &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;?&lt;/span&gt;&lt;span style="font-style: italic;"&gt; (if-true-value) &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;:&lt;/span&gt;&lt;span style="font-style: italic;"&gt; (else-value)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;for example,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;indecipherable = (true ? more : less);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;In this case, the operation of the ternary operator always makes the code more indecipherable.&lt;br /&gt;&lt;br /&gt;I think it is always bad news if the explanation for an operator is required before one can read it effectively. I wouldn't be surprised if the original author of this device eventually regretted his decision. It may have been created before the existence of the qwerty keyboard- and typists couldn't manage more than a few words per minute.&lt;br /&gt;&lt;br /&gt;I prefer a more verbose and natural style:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;if (predicate)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;t&gt; statements... &lt;/t&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{ &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;t&gt;statements... &lt;/t&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you discount the braces and other syntactic conventions, you aren't really gaining much typing efficiency by using the ternary operator. You are losing understandability and maintainability. As soon as more than one statement is required, the ternary operator must be refactored into an if-else block anyway.&lt;br /&gt;&lt;br /&gt;I know there is a party of programmers out there that are keen on jamming a whole bunch of logic into the smallest space possible. I think that sort of thinking is short-sighted. Understandability always trumps conciseness in programming. The ternary operator is a device from a long-gone era when this principle was not well understood.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5544444055644552303-8002672156854202933?l=dontcuddleyourbraces.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dontcuddleyourbraces.blogspot.com/feeds/8002672156854202933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5544444055644552303&amp;postID=8002672156854202933' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/8002672156854202933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/8002672156854202933'/><link rel='alternate' type='text/html' href='http://dontcuddleyourbraces.blogspot.com/2008/04/ternary-operator-considered-harmful.html' title='Ternary operator considered harmful'/><author><name>schwerwolf</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5544444055644552303.post-7228954341748404017</id><published>2007-10-26T20:31:00.000-07:00</published><updated>2007-10-26T21:41:28.059-07:00</updated><title type='text'>Multiline statement style</title><content type='html'>&lt;span style="font-size:100%;"&gt;There are occasions when it makes sense to extend a programming statement beyond one line:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);font-size:100%;" &gt;&lt;span style="font-family:courier new;"&gt;std::cerr &lt;&lt; "The following execution is " &lt;&lt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;"probably best placed on multiple lines. &lt;&lt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;std::endl;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;or, in another case:&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);font-size:100%;" &gt;&lt;span style="font-family:courier new;"&gt;if (the_job_is_finished &amp;amp;&amp;amp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;there_are_no_jobs_left &amp;amp;&amp;amp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(timer &gt; 10))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;Novices might be more acquainted with this formatting:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(102, 102, 102);font-family:courier new;" &gt;std::cerr &lt;&lt; "I am a novice programmer, and" &lt;/span&gt;&lt;span style="color: rgb(102, 102, 102);font-family:courier new;" &gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt; " I am still learning the   best-practices"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(102, 102, 102);font-family:courier new;" &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;&lt; " for programming style."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which better serves the paradigm of programming maintenance? I cannot contend against the aesthetics of the second, amateurish attempt. The alignment of the dual brackets is nothing if not captivating. But do they serve the purpose of easing the reading of the code? No. To demonstrate this inefficiency of this method, consider reading the code, one line at a time.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;&lt;span style="font-family:courier new;"&gt;std::cerr &lt;&lt; "I am a novice programmer, and"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153);"&gt;Great- a line is being printed to stderr.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;&lt;span style="font-family:courier new;"&gt;    &lt;&lt; " I am still learning the best-practices"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153);"&gt;...Wait- what does that "&lt;&lt;" mean- I've got to look at the previous line... Okay, now I see- we're continuing output.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The "..." indicate a momentary interruption to the left-to-right, top-down flow of code. This momentary interruption is significant because it requires the reader to investigate context in code that he has already read. This extra effort could be avoided with proper style.&lt;br /&gt;&lt;br /&gt;Now, consider the more efficient and excellent way:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;&lt;span style="font-family:courier new;"&gt;std::cerr &lt;&lt; "The following execution is " &lt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153);"&gt;A line is being printed to stderr and it appears the next line will continue the output.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 102);"&gt;&lt;span style="font-family:courier new;"&gt;     "probably best placed on multiple lines. &lt;&lt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 102);"&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Clearly this line is a continuation from the previous line of code.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Hundreds of years of typesetting have used hyphenation to indicate when a word extends beyond the line in which it commenced. I do not expect to ever see the follow&lt;br /&gt;-ing in a book. The practice of prefixing multiple line statements with an operator is akin to prefacing a line with a comma, or a hyphen- it's bad practice in typesetting- and it's bad practice in coding.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5544444055644552303-7228954341748404017?l=dontcuddleyourbraces.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dontcuddleyourbraces.blogspot.com/feeds/7228954341748404017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5544444055644552303&amp;postID=7228954341748404017' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/7228954341748404017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/7228954341748404017'/><link rel='alternate' type='text/html' href='http://dontcuddleyourbraces.blogspot.com/2007/10/multiline-statement-style.html' title='Multiline statement style'/><author><name>schwerwolf</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5544444055644552303.post-3643054091034635253</id><published>2007-10-16T05:56:00.001-07:00</published><updated>2007-10-16T06:02:59.392-07:00</updated><title type='text'>Apologies</title><content type='html'>I'd like to apologize for the previous post on build procedures. The subject matter had too much substance to be considered part of this blog. Nor did it give the opportunity for my nemesis to rebut the claims made therein. I've removed the post and put it in a more appropriate &lt;a href="http://schwerlog.blogspot.com/2007/10/build-procedures.html"&gt;location&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5544444055644552303-3643054091034635253?l=dontcuddleyourbraces.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dontcuddleyourbraces.blogspot.com/feeds/3643054091034635253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5544444055644552303&amp;postID=3643054091034635253' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/3643054091034635253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/3643054091034635253'/><link rel='alternate' type='text/html' href='http://dontcuddleyourbraces.blogspot.com/2007/10/apologies.html' title='Apologies'/><author><name>schwerwolf</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5544444055644552303.post-8540839568926229341</id><published>2007-10-10T07:13:00.001-07:00</published><updated>2007-10-10T08:08:40.157-07:00</updated><title type='text'>What is a header file?</title><content type='html'>My nemesis' &lt;a href="http://cuddleyourbraces.blogspot.com/2007/10/variable-names-in-c-function-prototypes.html"&gt;previous post&lt;/a&gt; is a little disturbing, both in its dense verbiage, and the lack understanding of a fundamental programming principle.&lt;br /&gt;&lt;br /&gt;The purpose of a header file is to define part of the contract for a function's invocation. If you leave out the names of function's parameters, in most cases there will not be enough information for the average developer to use a function. Consider the following function signature:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;void draw_Foobar_widget(&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;char *&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now consider the following:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;void draw_Foobar_widget(&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int width,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int height,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;char *title&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which is clearer?&lt;br /&gt;&lt;br /&gt;I suppose Mr.Cuddleyourbraces is trying to optimize the DRY principle at the detriment of the information hiding principle. The DRY principle encourages maintainable code. The information hiding principle encourages usable code. The developer who sees the first function definition is compelled to investigate the source code for the initializeFoobarWidget- and thus must confront all the complexity thereof. It is therefore a well-accepted convention to document the external view of a function in the header file. That means providing a function signature that is understandable without consulting the source code. And named function parameters.&lt;br /&gt;&lt;br /&gt;Using named function parameters in two places does violate the DRY principle, which is probably why some programming languages don't require a prior function signature (Java, perl, python, php, etc.) But you lose a lot more than you gain by observing the DRY principle to the extreme of not naming function parameters in your header files. The compiler cannot enforce good documentation via a man-page or something of that nature. The compiler &lt;b&gt;can&lt;/b&gt; enforce the existence of function signature. A well-disciplined programmer knows how to use them.&lt;br /&gt;&lt;br /&gt;Choose your poison:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Slightly more maintainable code that is never used.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Usable, well-designed software that takes an extra dash of discipline to maintain.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5544444055644552303-8540839568926229341?l=dontcuddleyourbraces.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dontcuddleyourbraces.blogspot.com/feeds/8540839568926229341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5544444055644552303&amp;postID=8540839568926229341' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/8540839568926229341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/8540839568926229341'/><link rel='alternate' type='text/html' href='http://dontcuddleyourbraces.blogspot.com/2007/10/what-is-header-file_10.html' title='What is a header file?'/><author><name>schwerwolf</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5544444055644552303.post-5934823649765494882</id><published>2007-10-03T11:39:00.000-07:00</published><updated>2007-10-03T12:30:53.734-07:00</updated><title type='text'>Against CamelCase</title><content type='html'>I can think of a few reasons why someone would choose camelCase in favor of underscore_delimited text.&lt;br /&gt;&lt;br /&gt;1. The underscore character doesn't have a convenient place on the keyboard.&lt;br /&gt;2. The shift key isn't working.&lt;br /&gt;3. You need to inscribe your code on gold leaf, so the extra character costs $.&lt;br /&gt;4. You forgot how to do &lt;a href="http://en.wikipedia.org/wiki/Hungarian_notation"&gt;hungarian notation&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I prefer underscore delimited text. Perhaps in the past there was a premium to be paid for writing software with variable names that were a few characters longer. Back then it made good sense to use a compressed notation. But nowadays, that notion is gone. So why does it continue to perpetuate itself? These are traditions that need to be overcome. I acknowledge that it is important to maintain the coding style of legacy software modules when modifying those modules. But how many &lt;span style="font-weight: bold;"&gt;new&lt;/span&gt; modules of code still adhere to the old conventions?&lt;br /&gt;&lt;br /&gt;I prefer underscore notation because it most closely mimics the convention used in natural language for delimiting words. And I don't think you need to capitalize the first letter of nouns (unless you're German), for every New_Word that appears in a variable name. I think the English rules for spelling and clauses are sufficient. I feel the same way about abbreviations. Making abbreviations for simple things like "copy -&gt; cp" might have made sense when working with 2K of system memory, but it doesn't simplify anyone's life when 5-6 years later someone doesn't know if you're trying to "compose", "compress", or "copy" someone's code. The whole camelCase fiasco promotes this idea; since it already looks outlandish- what's the harm in making it more outlandish by incorporating abbreviations?&lt;br /&gt;&lt;br /&gt;Abbreviations and camelCase in software implicitly encourage the notion that the hardest part of writing code is typing. Typing is the easy part. If it were the hardest part, we might expect a single developer to be able to write 50,000 lines of code in 6 weeks (that's 50,000 extremely dense lines at 60 wpm, 40 hrs/week).&lt;br /&gt;&lt;br /&gt;Nothing says "This is solid, tested code" like:&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;void initialize_distributed_system(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int number_of_clients,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int seconds_before_timeout,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;const char* log_filename)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;{ ... }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;and nothing induces nausea like:&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;void initDSys(&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int clientNm,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int tmoutSec,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;const char* logFname&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;{ ... }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;"Long live the underscore_delimiters!" -Dune (1984)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5544444055644552303-5934823649765494882?l=dontcuddleyourbraces.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dontcuddleyourbraces.blogspot.com/feeds/5934823649765494882/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5544444055644552303&amp;postID=5934823649765494882' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/5934823649765494882'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/5934823649765494882'/><link rel='alternate' type='text/html' href='http://dontcuddleyourbraces.blogspot.com/2007/10/against-camelcase.html' title='Against CamelCase'/><author><name>schwerwolf</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5544444055644552303.post-1615525378942822140</id><published>2007-09-28T11:53:00.000-07:00</published><updated>2007-09-28T12:30:53.452-07:00</updated><title type='text'>What does ++i mean?</title><content type='html'>What does "&lt;span style="font-family: courier new;"&gt;++i&lt;/span&gt;" mean? Well, it means "add 1 to i and return the value of i". This differs from "&lt;span style="font-family: courier new;"&gt;i++&lt;/span&gt;", which means "add 1 and return the value of i-1" or "return the value of i, then add 1 to it". Honestly, I'd prefer that such mechanisms weren't used as components of evaluated expressions. They are similar syntactically, but they differ in their results. These results are different enough to cause all sort of problems if not understood.&lt;br /&gt;&lt;br /&gt;Performance-wise, historically "&lt;span style="font-family: courier new;"&gt;++i&lt;/span&gt;" has been favored. I'm not sure exactly why it had better performance. But I'm convinced that this performance difference is unobservable in the light of current CPU and compiler technology.&lt;br /&gt;&lt;br /&gt;I must admit that the behavior of the "&lt;span style="font-family: courier new;"&gt;i++&lt;/span&gt;" operation is more confusing. Unlike most expressions, it returns the value of the variable &lt;b&gt;before&lt;/b&gt; the operation occurs, rather than after. This is a break in coherence with the "+" operator. Or any operator, for that matter.&lt;br /&gt;&lt;br /&gt;So why am I supporting the postfix "&lt;span style="font-family: courier new;"&gt;i++&lt;/span&gt;" operator over the prefix operator? Not because its returned value is more sensible. I think I've established that using these operators in evaluated expressions is a no-no. Rather, I prefer "&lt;span style="font-family: courier new;"&gt;i++&lt;/span&gt;" because it more closely resembles its mathematical analogue: "i = i + 1". What does "&lt;span style="font-family: courier new;"&gt;++i&lt;/span&gt;" resemble?: "1 + i = i". That lacks any coherence with mathematics- it suggests an operation opposite of its actual result. In the end "&lt;span style="font-family: courier new;"&gt;i++&lt;/span&gt;" trades coherence &lt;span style="font-weight: bold;"&gt;within &lt;/span&gt;the programming language for coherence &lt;span style="font-weight: bold;"&gt;with&lt;/span&gt; the language of mathematics. And "&lt;span style="font-family: courier new;"&gt;++i&lt;/span&gt;" does the opposite. And I prefer mathematics.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5544444055644552303-1615525378942822140?l=dontcuddleyourbraces.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dontcuddleyourbraces.blogspot.com/feeds/1615525378942822140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5544444055644552303&amp;postID=1615525378942822140' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/1615525378942822140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/1615525378942822140'/><link rel='alternate' type='text/html' href='http://dontcuddleyourbraces.blogspot.com/2007/09/what-does-i-mean.html' title='What does ++i mean?'/><author><name>schwerwolf</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5544444055644552303.post-3724032974469068117</id><published>2007-09-27T12:02:00.001-07:00</published><updated>2007-09-27T12:37:25.996-07:00</updated><title type='text'>An endless rebuttal</title><content type='html'>In response to this &lt;a href="http://cuddleyourbraces.blogspot.com/2007/09/evils-of-whiletrue-loop.html"&gt;travesty of an argument...&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;a while loop is really a syntactic sugar for the more general for loop in which a condition is &lt;span style="font-weight: bold;"&gt;expected to be false&lt;/span&gt; at some time during its execution.&lt;/i&gt;&lt;br /&gt;Who says a condition is "expected to be false"? Maybe we're writing server code and the loop really is intended to continue forever.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:courier new;" &gt;for (;;) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;font-family:courier new;" &gt;}&lt;/span&gt;&lt;br /&gt;&lt;i&gt;It &lt;span style="font-weight: bold;"&gt;simply and clearly states&lt;/span&gt; that a loop will continue to iterate until some internal condition dictates that it is now time to break out.&lt;/i&gt;&lt;br /&gt;That's poppycock. How many steps in translation does it take to get from "for(;;)" to "loop forever". Once you've learned that "for" means "loop", then you've got to figure out that "(;;)" means "forever". I know that seems pretty simple to all you veteran programmers out there, but I'd prefer to save brain-space for something more useful. The "while(true)" construct doesn't compel me to maintain two definitions for "while" in my brainspace (I speak english natively). While means while and true means true. Granted, we could extend the syntax with prepositions. But no semicolons, that's for sure.&lt;br /&gt;&lt;br /&gt;I know what you're thinking: "English isn't C and C isn't English. If you're overlapping languages in this way, you're bound to mess something up." I agree. I'm just saying that there's no sense in creating new syntax if the old syntax is just as effective at accomplishing the same task. In this case, while(true), English is just as effective. (When I say effective, I mean "well-designed").&lt;br /&gt;&lt;br /&gt;Finally, I think we could both agree that any language would be better served with a "loop" construct that doesn't require any condition for execution. My opinion is that the following construction is preferable to either while(true), or (the ghastly) for (;;):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;loop&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;do_something();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (something_happened())&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I've learned from sad experience that the order of execution in a loop can make a big difference when it comes to the correctness of the code. Because the exit condition is explicitly located relative to the processing, there's no ambiguity.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5544444055644552303-3724032974469068117?l=dontcuddleyourbraces.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dontcuddleyourbraces.blogspot.com/feeds/3724032974469068117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5544444055644552303&amp;postID=3724032974469068117' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/3724032974469068117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/3724032974469068117'/><link rel='alternate' type='text/html' href='http://dontcuddleyourbraces.blogspot.com/2007/09/endless-rebuttal.html' title='An endless rebuttal'/><author><name>schwerwolf</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5544444055644552303.post-726856437939972110</id><published>2007-09-25T14:00:00.000-07:00</published><updated>2007-09-25T14:07:42.356-07:00</updated><title type='text'>Cuddle-schmuddle</title><content type='html'>See this &lt;a href="http://cuddleyourbraces.blogspot.com/2007/09/why-it-is-important-to-cuddel-your.html"&gt;sorry excuse for an argument&lt;/a&gt;.&lt;br /&gt;I'm not falling for the "subordinate" argument- if we follow that line of thinking to its conclusion, we'd avoid using whitespace altogether. The statements below the if statement are clearly subordinate to the if clause because it is indented. I haven't ever heard of a misunderstanding induced by this "unclear" subordination principle. I &lt;b&gt;have&lt;/b&gt; seen many coding errors induced because the maintainer either cuddled their braces or expected the previous coder to have cuddled them. Cuddling is madness.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5544444055644552303-726856437939972110?l=dontcuddleyourbraces.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dontcuddleyourbraces.blogspot.com/feeds/726856437939972110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5544444055644552303&amp;postID=726856437939972110' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/726856437939972110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/726856437939972110'/><link rel='alternate' type='text/html' href='http://dontcuddleyourbraces.blogspot.com/2007/09/cuddle-schmuddle.html' title='Cuddle-schmuddle'/><author><name>schwerwolf</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5544444055644552303.post-4662847054906005424</id><published>2007-09-25T12:32:00.000-07:00</published><updated>2007-09-25T12:41:27.314-07:00</updated><title type='text'>Onward coding soldiers...</title><content type='html'>This blog is intended to serve as a resource to those in the fight to establish uncuddled braces as a the industry standard coding style.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:courier new;"&gt;if (you.cuddle_your_braces())&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;you = crazy;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;happiness.awaits();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: left;"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5544444055644552303-4662847054906005424?l=dontcuddleyourbraces.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dontcuddleyourbraces.blogspot.com/feeds/4662847054906005424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5544444055644552303&amp;postID=4662847054906005424' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/4662847054906005424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5544444055644552303/posts/default/4662847054906005424'/><link rel='alternate' type='text/html' href='http://dontcuddleyourbraces.blogspot.com/2007/09/onward-coding-soldiers.html' title='Onward coding soldiers...'/><author><name>schwerwolf</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry></feed>
