<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx</link><description>When we last left the code we were looking at, it looked like: #include "list.h" main(C cArg, SZ rgszArg[]) { I iNode, cNodes = atoi(rgszArg[1]), cNodesToSkip = atoi(rgszArg[2]); PNODE pnodeT, pnodeCur; InitNodes(cNodes); for (iNode = 2, pnodeCur = PnodeNew(1);</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#255911</link><pubDate>Thu, 11 Nov 2004 20:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:255911</guid><dc:creator>James H.</dc:creator><description>Of those, my style is most like your modified BSD style.&lt;br&gt;&lt;br&gt;For instance (pardon my Java... I've got it on the brain at the moment..):&lt;br&gt;&lt;br&gt;import javax.swing.*;&lt;br&gt;&lt;br&gt;public class Sample&lt;br&gt;{&lt;br&gt;    public Sample ()&lt;br&gt;    {&lt;br&gt;        // Blah blah blah&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    public static void main ( String[] args )&lt;br&gt;    {&lt;br&gt;        for ( int i = 0; i &amp;lt; args.length; i++ )&lt;br&gt;        {&lt;br&gt;            System.out.println ( args[ i ] );&lt;br&gt;        }&lt;br&gt;    }&lt;br&gt;}&lt;br&gt;&lt;br&gt;I'm all about the white space.  I think it makes my code easy to read.  Also, notice that in Java I used the square array brackets on the variable type, and not the name.  To me, this helps me know that much faster that I'm dealing with an array.&lt;br&gt;&lt;br&gt;The only other &amp;quot;real&amp;quot; language I know is C, and my style is almost identical.&lt;br&gt;&lt;br&gt;The only problem is that when I have to hand in assignments (Still a student), this style takes up a LOT of paper and sometimes is butchered by print margins.</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#255917</link><pubDate>Thu, 11 Nov 2004 20:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:255917</guid><dc:creator>Mike Dunn</dc:creator><description>&amp;quot;braces appear on the same line as the code they wrap&amp;quot; is the only way to fly. Not indenting the braces is ok too, but it's just not the style I use or am used to.&lt;br&gt; &lt;br&gt;Having the opening brace on the same line as the if/for/while is definitely worse because when you're looking at a } it's *much* harder to quickly scan the code and find the matching {.  Sure, you can hit ^] in VC to find it, but you don't always have VC at your disposal.&lt;br&gt; &lt;br&gt;Having each { and } on its own line also gives some much-needed vertical whitespace. There's nothing I hate more than seeing a big ol' block of code with no vertical spacing to indicate logical breaks in the logic flow.</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#255936</link><pubDate>Thu, 11 Nov 2004 21:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:255936</guid><dc:creator>Björn Roth</dc:creator><description>Agreed. I would also punch a newline after the for- and while-blocks to make them stand out further.</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#255937</link><pubDate>Thu, 11 Nov 2004 21:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:255937</guid><dc:creator>Larry Osterman</dc:creator><description>Funny you should mention that Bjorn, that change comes up during the comments discussion tomorrow :)&lt;br&gt;</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#255946</link><pubDate>Thu, 11 Nov 2004 21:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:255946</guid><dc:creator>Srdjan</dc:creator><description>My style is 'modified BSD' -- as other readers suggest, it gives you more vertical white space (I would put another one blank like after variables' declarations)...</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#255957</link><pubDate>Thu, 11 Nov 2004 21:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:255957</guid><dc:creator>David Candy</dc:creator><description>You're all wimps with this structured code. Surveycraft is basic pseudocode (as real survercraft variables are names after the line number created on)&lt;br&gt;&lt;br&gt;10 10=input &amp;quot;enter something&amp;quot;&lt;br&gt;&lt;br&gt;20 20=input &amp;quot;enter something&amp;quot;&lt;br&gt;&lt;br&gt;30 msgbox 10&lt;br&gt;&lt;br&gt;40 msgbox 20&lt;br&gt;&lt;br&gt;50&lt;br&gt;&lt;br&gt;15 If 10 = &amp;quot;dog&amp;quot; then goto 30&lt;br&gt;&lt;br&gt;35 If 20 = &amp;quot;&amp;quot; then goto 50&lt;br&gt;&lt;br&gt;&lt;br&gt;Now this is real coding style. Seperating actions from flow. Makes C coding style debates seem really minor. Lucky it has gone out of fashion.</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256062</link><pubDate>Thu, 11 Nov 2004 23:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256062</guid><dc:creator>Skywing</dc:creator><description>BTW, it's not legal in either C++ or C99 to leave out the 'int' return type for main (though it is legal to omit 'return')...</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256064</link><pubDate>Thu, 11 Nov 2004 23:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256064</guid><dc:creator>Larry Osterman</dc:creator><description>You're right Skywing, but that's the sample as it appears in the book, so...&lt;br&gt;</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256072</link><pubDate>Fri, 12 Nov 2004 00:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256072</guid><dc:creator>Mike Dimmick</dc:creator><description>Mine's 'modified BSD', but I normally put a blank line before a new control structure (unless right after an opening brace), after closing a control structure (unless right before a closing brace), and between declarations and code, so I'd insert a blank line after line 1, 8, 9, 15, 21 and 23 (of your third example, where you put each declaration on its own line).&lt;br&gt;&lt;br&gt;This style really emphasises control structure. I also put spaces inside parentheses unless the parens indicate a cast. In C languages, I always put a space between a control keyword and the controlled expression but never between a function call and its parameter list [e.g. if ( x ) but f( x )]. OK, it takes a lot of lines - and I follow the rule of not allowing a function to take more than a couple of screenfuls, but then a screenful is a lot of lines on current monitors. Personally I can't stand horizontal scrolling; if I must break a function call, for example, I'll normally break after the opening paren and after every argument (i.e. either all-on-one-line or one-argument-per-line).</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256126</link><pubDate>Fri, 12 Nov 2004 01:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256126</guid><dc:creator>Michael</dc:creator><description>OK, I figured we could ask the 'K' of K&amp;amp;R and maybe get a deep response.  &lt;br&gt;-------------------&lt;br&gt;From: Brian Kernighan&lt;br&gt;Sent: Thursday, November 11, 2004 5:58 PM&lt;br&gt;To: Michael&lt;br&gt;Subject: Re: Braces, indention, etc.&lt;br&gt;&lt;br&gt;i just copied what ken and dennis did, if i remember right.  nothing very deep.&lt;br&gt;-------------------&lt;br&gt;OK, nothing good there.  I'll see if I can get Ken to offer up something...</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256139</link><pubDate>Fri, 12 Nov 2004 01:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256139</guid><dc:creator>Norman Diamond</dc:creator><description>&amp;gt; Just for grins, the style of a senior&lt;br&gt;&amp;gt; developer within Microsoft&lt;br&gt;&lt;br&gt;Are you sure he indented by 4 columns not 3?&lt;br&gt;&lt;br&gt;IBM PL/I manuals put the &amp;quot;DO;&amp;quot; at the end of a line as in OTBS, but indented the &amp;quot;END;&amp;quot; at the same level as the nested statements instead of outdenting it back to the &amp;quot;IF&amp;quot; or &amp;quot;WHILE&amp;quot; or whatever initiated the do-group.  If I recall correctly, those same IBM PL/I manuals indented code by multiples of 3 columns.  (And oh yeah, don't forget to leave 1 blank in column 1 of every line unless you're going to submit a compile listing to the International Obfuscated PL/I Coding Contest.)&lt;br&gt;&lt;br&gt;Unfortunately I don't know MULTICS PL/I style.  Can anyone else say?</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256146</link><pubDate>Fri, 12 Nov 2004 02:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256146</guid><dc:creator>Larry Osterman</dc:creator><description>I'm pretty sure it was 4 (although I may be wrong, I'm resurrecting his style from memory, the code he worked on no longer displays this style).  To my knowledge, this developer never worked in PL/I.&lt;br&gt;&lt;br&gt;Ah, found some code that hadn't been &amp;quot;cleaned&amp;quot; up.  Yup, it was 4.  </description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256189</link><pubDate>Fri, 12 Nov 2004 04:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256189</guid><dc:creator>Phaeron</dc:creator><description>I've seen some style guides (SGI?) that specify #1 for control structures but #2 for functions.&lt;br&gt;&lt;br&gt;The most unique style I ever had to match was:&lt;br&gt;&lt;br&gt;  if(condition){&lt;br&gt;      doSomething();&lt;br&gt;  }&lt;br&gt;  else{&lt;br&gt;      doSomethingElse();&lt;br&gt;  }&lt;br&gt;&lt;br&gt;It wasn't hard to pick up given a K&amp;amp;R background, but it looked very strange the first time I saw it.&lt;br&gt;</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256574</link><pubDate>Fri, 12 Nov 2004 17:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256574</guid><dc:creator>Travis</dc:creator><description>I vote for modified BSD or the one following &amp;quot;lets split them (the declarations) out into separate lines.&amp;quot; Opening up the code, like you say, makes it easier to see what's going on with a glance, rather than having to read it. This reason (glance vs. read) is why I like languages with C-style syntax over languanges with VB-style syntax. It's just easier to see what's going on.</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256604</link><pubDate>Fri, 12 Nov 2004 18:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256604</guid><dc:creator>Greg Buchholz</dc:creator><description>I'm a modified BSD man when it comes to C, but it looks like the main reason why this code is so dog-ugly (I mean besides the whole Hungarian mess) is that it should've been written in an altogether different language.  Something with native lists and higher-order functions please.  </description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256607</link><pubDate>Fri, 12 Nov 2004 18:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256607</guid><dc:creator>Larry Osterman</dc:creator><description>Greg, you're confusing the content with the style.  The content is irrelevant, it's the style that counts.&lt;br&gt;&lt;br&gt;Maybe I should have written up a function that did absolutely nothing, but for better or for worse, I chose a real example.&lt;br&gt;</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256636</link><pubDate>Fri, 12 Nov 2004 19:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256636</guid><dc:creator>Greg Buchholz</dc:creator><description>I can understand why you want to separate style from content, but is it always that easy?  Is style only concerned with indenting and carriage returns?   I would view choosing i++ vs. i+=1 vs. i=i+1 to be a style issue.  Also consider making a speed vs. elegance trade-off.  Is that not an issue of style?  As you stated on Tuesday, &amp;quot;A good coding style should result in high quality self-documented code that is esthetically pleasing to look at.&amp;quot;  It might be interesting to discuss these ideas, even if you don't agree that these are issues of 'style'.</description></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256640</link><pubDate>Fri, 12 Nov 2004 19:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256640</guid><dc:creator>Larry Osterman</dc:creator><description>No, it's not always that easy.  But for the purposes of this discussion, I don't want to get into whether or not a particular piece of code should be written with a different library (or a different language).&lt;br&gt;&lt;br&gt;The problem is that external constraints prevent many of those choices (for example, using STL in a windows device driver is invariably a bad idea), so while it might be cleaner to use STL, it might not be possible.&lt;br&gt;&lt;br&gt;Whereas these articles are language and situation neutral (or at least I'm trying to make them so).&lt;br&gt;</description></item><item><title>What does style look like, part 4</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#256646</link><pubDate>Fri, 12 Nov 2004 22:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:256646</guid><dc:creator>Larry Osterman's WebLog</dc:creator><description /></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#257305</link><pubDate>Mon, 15 Nov 2004 02:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:257305</guid><dc:creator>Norman Diamond</dc:creator><description>11/12/2004 11:06 AM Greg Buchholz&lt;br&gt;&lt;br&gt;&amp;gt; I would view choosing i++ vs. i+=1 vs. i=i+1&lt;br&gt;&amp;gt; to be a style issue.&lt;br&gt;&lt;br&gt;Close.  ++i vs. i+=1 vs. i=i+1 is a style issue.  (Also the possibility of inserting whitespace into any or all of those is a style issue.[*])  But i++ yields a different answer.  Of course it's also a style issue whether to ever write code that directly uses the result of either ++i or i++, but when reading code you'd better be aware that they yield different answers.&lt;br&gt;&lt;br&gt;[* Actually it wasn't always a style issue.  Operator += used to be operator =+ which didn't matter much because there was no unary +, but operator =- used to be operator =- and it mattered.  If you wanted to do a = - b then you could omit the space between - and b but you couldn't omit the space between = and -.  This resulted in enough bugs that DMR changed the language.  This change was only needed for code/coders who didn't use whitespace where it was necessary.  This also gave me an opportunity to mouth off at DMR in comp.lang.c around 15 years ago.  In response to someone else's posting, he posted &amp;quot;whitespace is your friend&amp;quot;.  I retorted that if he really believed that then he wouldn't have changed =- to -=.]</description></item><item><title>Geek Noise 2004-11-28</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#272090</link><pubDate>Tue, 30 Nov 2004 08:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:272090</guid><dc:creator>Geek Noise</dc:creator><description /></item><item><title>re: What does style look like, part 3</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#272538</link><pubDate>Tue, 30 Nov 2004 22:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:272538</guid><dc:creator>Nick</dc:creator><description>First &amp;quot;modified BSD&amp;quot; of course; minus the Hungarian, and you're getting somewhere :)&lt;br&gt;</description></item><item><title> Larry Osterman s WebLog What does style look like part 3 | Insomnia Cure</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#9710822</link><pubDate>Tue, 09 Jun 2009 01:49:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9710822</guid><dc:creator> Larry Osterman s WebLog What does style look like part 3 | Insomnia Cure</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://insomniacuresite.info/story.php?id=11355"&gt;http://insomniacuresite.info/story.php?id=11355&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Larry Osterman s WebLog What does style look like part 3 | Hair Growth Products</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#9713831</link><pubDate>Tue, 09 Jun 2009 11:17:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9713831</guid><dc:creator> Larry Osterman s WebLog What does style look like part 3 | Hair Growth Products</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://hairgrowthproducts.info/story.php?id=7124"&gt;http://hairgrowthproducts.info/story.php?id=7124&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Larry Osterman s WebLog What does style look like part 3 | Outdoor Decor</title><link>http://blogs.msdn.com/larryosterman/archive/2004/11/11/255892.aspx#9778928</link><pubDate>Fri, 19 Jun 2009 07:14:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9778928</guid><dc:creator> Larry Osterman s WebLog What does style look like part 3 | Outdoor Decor</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://outdoordecoration.info/story.php?id=4518"&gt;http://outdoordecoration.info/story.php?id=4518&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>