<?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 7</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx</link><description>Over the course of this series on style, I've touched on a lot of different aspects, today I want to discuss aspects C and C++ style specifically. One of the things about computer languages in general is that there are often a huge number of options available</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title> Larry Osterman s WebLog What does style look like part 7 | Outdoor Decor</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx#9778872</link><pubDate>Fri, 19 Jun 2009 07:10:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9778872</guid><dc:creator> Larry Osterman s WebLog What does style look like part 7 | Outdoor Decor</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://outdoordecoration.info/story.php?id=4496"&gt;http://outdoordecoration.info/story.php?id=4496&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9778872" width="1" height="1"&gt;</description></item><item><title> Larry Osterman s WebLog What does style look like part 7 | Hair Growth Products</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx#9744377</link><pubDate>Sat, 13 Jun 2009 15:11:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9744377</guid><dc:creator> Larry Osterman s WebLog What does style look like part 7 | Hair Growth Products</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://hairgrowthproducts.info/story.php?id=7103"&gt;http://hairgrowthproducts.info/story.php?id=7103&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9744377" width="1" height="1"&gt;</description></item><item><title> Larry Osterman s WebLog What does style look like part 7 |  Portable Greenhouse</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx#9681053</link><pubDate>Mon, 01 Jun 2009 22:40:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9681053</guid><dc:creator> Larry Osterman s WebLog What does style look like part 7 |  Portable Greenhouse</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://portablegreenhousesite.info/story.php?id=14525"&gt;http://portablegreenhousesite.info/story.php?id=14525&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9681053" width="1" height="1"&gt;</description></item><item><title> Larry Osterman s WebLog What does style look like part 7 | Wood TV Stand</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx#9678959</link><pubDate>Mon, 01 Jun 2009 20:42:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9678959</guid><dc:creator> Larry Osterman s WebLog What does style look like part 7 | Wood TV Stand</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://woodtvstand.info/story.php?id=7041"&gt;http://woodtvstand.info/story.php?id=7041&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9678959" width="1" height="1"&gt;</description></item><item><title>re: What does style look like, part 7</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx#271999</link><pubDate>Tue, 30 Nov 2004 01:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:271999</guid><dc:creator>Larry Osterman</dc:creator><description>Sean,&lt;br&gt;  That only works if Method1() doesn't have side effects (like allocating memory).&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=271999" width="1" height="1"&gt;</description></item><item><title>re: What does style look like, part 7</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx#271997</link><pubDate>Tue, 30 Nov 2004 01:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:271997</guid><dc:creator>Sean Malloy</dc:creator><description>IMO, I would break the single return point rule rather than use a goto.&lt;br&gt;&lt;br&gt;#define HANDLE_FAILURE(hr) if ((hr) != S_OK) return hr;&lt;br&gt;HRESULT MyFunction()&lt;br&gt;{&lt;br&gt;    HRESULT hr;&lt;br&gt;&lt;br&gt;    hr = myCOMObject-&amp;gt;Method1();&lt;br&gt;    HANDLE_FAILURE(hr);&lt;br&gt;&lt;br&gt;    hr = myCOMObject-&amp;gt;Method2();&lt;br&gt;    HANDLE_FAILURE(hr);&lt;br&gt;&lt;br&gt;    hr = myCOMObject-&amp;gt;Method3();&lt;br&gt;    HANDLE_FAILURE(hr);&lt;br&gt;    &lt;br&gt;    hr = myCOMObject-&amp;gt;Method4();&lt;br&gt;    HANDLE_FAILURE(hr);&lt;br&gt;&lt;br&gt;    hr = myCOMObject-&amp;gt;Method5();&lt;br&gt;    HANDLE_FAILURE(hr);&lt;br&gt;&lt;br&gt;    return hr;&lt;br&gt;}&lt;br&gt;&lt;br&gt;ofcourse, if you have cleanup code there's an issue that can be solved by a goto (as you suggested)&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=271997" width="1" height="1"&gt;</description></item><item><title>re: What does style look like, part 7</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx#267748</link><pubDate>Mon, 22 Nov 2004 04:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:267748</guid><dc:creator>Norman Diamond</dc:creator><description>11/18/2004 6:21 PM Larry Osterman&lt;br&gt;&lt;br&gt;&amp;gt; There IS a semantic difference between i++&lt;br&gt;&amp;gt; and ++i in the language,&lt;br&gt;&lt;br&gt;Right.&lt;br&gt;&lt;br&gt;&amp;gt; but there isn't a semantic difference&lt;br&gt;&amp;gt; between i++ and i+=1 (assuming that they&lt;br&gt;&amp;gt; appear in a statement with equivilant&lt;br&gt;&amp;gt; operator precedence).&lt;br&gt;&lt;br&gt;Wrong.  There isn't a semantic difference between ++i and i+=1 (assuming your  ssumption).  There is a semantic difference between i++ and i+=1 except when you're discarding the result.  (Of course style and readability do call for discarding the result and only letting i benefit from the side effect, but the language definition doesn't.)&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=267748" width="1" height="1"&gt;</description></item><item><title>re: What does style look like, part 7</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx#267164</link><pubDate>Sat, 20 Nov 2004 06:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:267164</guid><dc:creator>Larry Osterman</dc:creator><description>Actually my issues with templates are directly related to my issues with operator overloads: They hide complexity.  Templates add the additional problem of hiding code size.&lt;br&gt;&lt;br&gt;It's not always clear to people that having:&lt;br&gt;&lt;br&gt;std::vector&amp;lt;std::string&amp;gt; stringArray;&lt;br&gt;std::vector&amp;lt;int&amp;gt; intArray&lt;br&gt;&lt;br&gt;brings in two complete copies of std::vector (and two copies of everything that std::vector uses) into their application.  That's the biggest evil of templates.  I've seen real-world examples of unbelievable code bloat brought on by templates.&lt;br&gt;&lt;br&gt;The good news is that current linkers help to ameliorate this problem (by collapsing identical functions), which means that CComPtr&amp;lt;IUnknown&amp;gt; and CComPtr&amp;lt;IDispatch&amp;gt; can share implementations (otherwise you'd have a separate completely identical implementations of CComPtr for every single COM object your program used).&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=267164" width="1" height="1"&gt;</description></item><item><title>re: What does style look like, part 7</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx#267104</link><pubDate>Sat, 20 Nov 2004 01:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:267104</guid><dc:creator>James</dc:creator><description>Larry,&lt;br&gt;&lt;br&gt;While I don't necessarily agree with all of your sentiments, I do agree with your rationale that ease of maintenance is critical.&lt;br&gt;&lt;br&gt;Please allow me to suggest the Bulka and Mayhew book &amp;quot;Efficient C++&amp;quot; to people who are concerned about operator overloading in C++ after reading your reply. Overloading is syntactic sugar for making a function call, but as you suggest, you should understand the implications of making such a call.&lt;br&gt;&lt;br&gt;As for templates, that's a discussion for another day. I could argue strongly in their favour (compare std::sort to qsort), but no doubt you have arguments as to their complexity (for authors at least).&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=267104" width="1" height="1"&gt;</description></item><item><title>re: What does style look like, part 7</title><link>http://blogs.msdn.com/b/larryosterman/archive/2004/11/17/259033.aspx#266110</link><pubDate>Fri, 19 Nov 2004 02:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:266110</guid><dc:creator>Larry Osterman</dc:creator><description>James,&lt;br&gt;  &amp;lt;snarky&amp;gt;STL?  What's that?  It's not part of the core language, is it?&amp;lt;/snarky&amp;gt;&lt;br&gt;&lt;br&gt;My comment's snarky but it's relevent.  Just because the STL authors chose to ignore the semantics of the language isn't the fault of the language.&lt;br&gt;&lt;br&gt;There IS a semantic difference between i++ and ++i in the language, but there isn't a semantic difference between i++ and i+=1 (assuming that they appear in a statement with equivilant operator precedence).&lt;br&gt;&lt;br&gt;Remember my comment about style in the final post in the series: Style's about improving the maintainability of code.  Any use of constructs that do NOT improve the readability of code should be avoided at all costs.&lt;br&gt;&lt;br&gt;And I personally consider operator overloads of all sorts to be a classic example of a situation where complexity is unnecessarily added (it's without a doubt my least favorite language feature, closely followed by templates).  We've been through that particular discussion before (see the all developers must know assembly language post for more info, it's in the archives).&lt;br&gt;&lt;br&gt;Just consider that one senior developer spent literally a year doing nothing but dealing with the consequences of a development team choosing to use operator overloads in a performance critical portion of the operating system, and you'll understand where my issues come from.  Operator overloads hide code and thus hide complexity, which is utterly unacceptable in high performance systems code.&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=266110" width="1" height="1"&gt;</description></item></channel></rss>