<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[100 wichtige Regeln für C++ Programmierer]]></title><description><![CDATA[<p><strong>A. Organizational and Policy Issues.</strong></p>
<ol start="0">
<li>Don't sweat the small stuff. (Or: Know what not to standardize.).</li>
<li>Compile cleanly at high warning levels.</li>
<li>Use an automated build system.</li>
<li>Use a version control system.</li>
<li>Invest in code reviews.</li>
</ol>
<p><strong>B. Design Style.</strong></p>
<ol start="5">
<li>Give one entity one cohesive responsibility.</li>
<li>Correctness, simplicity, and clarity come first.</li>
<li>Know when and how to code for scalability.</li>
<li>Don't optimize prematurely.</li>
<li>Don't pessimize prematurely.</li>
<li>Minimize global and shared data.</li>
<li>Hide information.</li>
<li>Know when and how to code for concurrency.</li>
<li>Ensure resources are owned by objects. Use explicit RAII and smart pointers.</li>
</ol>
<p><strong>C. Coding Style.</strong></p>
<ol start="14">
<li>Prefer compile- and link-time errors to run-time errors.</li>
<li>Use const proactively.</li>
<li>Avoid macros.</li>
<li>Avoid magic numbers.</li>
<li>Declare variables as locally as possible.</li>
<li>Always initialize variables.</li>
<li>Avoid long functions. Avoid deep nesting.</li>
<li>Avoid initialization dependencies across compilation units.</li>
<li>Minimize definitional dependencies. Avoid cyclic dependencies.</li>
<li>Make header files self-sufficient.</li>
<li>Always write internal #include guards. Never write external #include guards.</li>
</ol>
<p><strong>D. Functions and Operators.</strong></p>
<ol start="25">
<li>Take parameters appropriately by value, (smart) pointer, or reference.</li>
<li>Preserve natural semantics for overloaded operators.</li>
<li>Prefer the canonical forms of arithmetic and assignment operators.</li>
<li>Prefer the canonical form of ++ and --. Prefer calling the prefix forms.</li>
<li>Consider overloading to avoid implicit type conversions.</li>
<li>Avoid overloading &amp;&amp;, ||, or , (comma)</li>
<li>Don't write code that depends on the order of evaluation of functionarguments.</li>
</ol>
<p><strong>E. Class Design and Inheritance.</strong></p>
<ol start="32">
<li>Be clear what kind of class you're writing.</li>
<li>Prefer minimal classes to monolithic classes.</li>
<li>Prefer composition to inheritance.</li>
<li>Avoid inheriting from classes that were not designed to be base classes.</li>
<li>Prefer providing abstract interfaces.</li>
<li>Public inheritance is substitutability. Inherit, not to reuse, but to be reused.</li>
<li>Practice safe overriding.</li>
<li>Consider making virtual functions nonpublic, and public functions nonvirtual.</li>
<li>Avoid providing implicit conversions.</li>
<li>Make data members private, except in behaviorless aggregates (C-stylestructs).</li>
<li>Don't give away your internals.</li>
<li>Pimpl judiciously.</li>
<li>Prefer writing nonmember nonfriend functions.</li>
<li>Always provide new and delete together.</li>
<li>If you provide any class-specific new, provide all of the standard forms (plain, in-place, and nothrow).</li>
</ol>
<p><strong>F. Construction, Destruction, and Copying.</strong></p>
<ol start="47">
<li>Define and initialize member variables in the same order.</li>
<li>Prefer initialization to assignment in constructors.</li>
<li>Avoid calling virtual functions in constructors and destructors.</li>
<li>Make base class destructors public and virtual, or protected and nonvirtual.</li>
<li>Destructors, deallocation, and swap never fail.</li>
<li>Copy and destroy consistently.</li>
<li>Explicitly enable or disable copying.</li>
<li>Avoid slicing. Consider Clone instead of copying in base classes.</li>
<li>Prefer the canonical form of assignment.</li>
<li>Whenever it makes sense, provide a no-fail swap (and provide it correctly).</li>
</ol>
<p><strong>G. Namespaces and Modules.</strong></p>
<ol start="57">
<li>Keep a type and its nonmember function interface in the same namespace.</li>
<li>Keep types and functions in separate namespaces unless they're specifically intended to work together.</li>
<li>Don't write namespace usings in a header file or before an #include.</li>
<li>Avoid allocating and deallocating memory in different modules.</li>
<li>Don't define entities with linkage in a header file.</li>
<li>Don't allow exceptions to propagate across module boundaries.</li>
<li>Use sufficiently portable types in a module's interface.</li>
<li>Blend static and dynamic polymorphism judiciously.</li>
<li>Customize intentionally and explicitly.</li>
<li>Don't specialize function templates.</li>
<li>Don't write unintentionally nongeneric code.</li>
</ol>
<p><strong>H. Templates and Genericity.</strong></p>
<ol start="68">
<li>Assert liberally to document internal assumptions and invariants.</li>
<li>Establish a rational error handling policy, and follow it strictly.</li>
<li>Distinguish between errors and non-errors.</li>
<li>Design and write error-safe code.</li>
<li>Prefer to use exceptions to report errors.</li>
<li>Throw by value, catch by reference.</li>
<li>Report, handle, and translate errors appropriately.</li>
<li>Avoid exception specifications.</li>
</ol>
<p><strong>I. Error Handling and Exceptions.</strong></p>
<ol start="76">
<li>Use vector by default. Otherwise, choose an appropriate container.</li>
<li>Use vector and string instead of arrays.</li>
<li>Use vector (and string::c_str) to exchange data with non-C++ APIs.</li>
<li>Store only values and smart pointers in containers.</li>
<li>Prefer push_back to other ways of expanding a sequence.</li>
<li>Prefer range operations to single-element operations.</li>
<li>Use the accepted idioms to really shrink capacity and really erase elements.</li>
</ol>
<p><strong>J. STL: Containers.</strong></p>
<ol start="83">
<li>Use a checked STL implementation.</li>
<li>Prefer algorithm calls to handwritten loops.</li>
<li>Use the right STL search algorithm.</li>
<li>Use the right STL sort algorithm.</li>
<li>Make predicates pure functions.</li>
<li>Prefer function objects over functions as algorithm and comparer arguments.</li>
<li>Write function objects correctly.</li>
</ol>
<p><strong>K. Type Safety.</strong></p>
<ol start="90">
<li>Avoid type switching; prefer polymorphism.</li>
<li>Rely on types, not on representations.</li>
<li>Avoid using reinterpret_cast.</li>
<li>Avoid using static_cast on pointers.</li>
<li>Avoid casting away const.</li>
<li>Don't use C-style casts.</li>
<li>Don't memcpy or memcmp non-PODs.</li>
<li>Don't use unions to reinterpret representation.</li>
<li>Don't use varargs (ellipsis).</li>
<li>Don't use invalid objects. Don't use unsafe functions.</li>
<li>Don't treat arrays polymorphically.</li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/topic/106960/100-wichtige-regeln-für-c-programmierer</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 08:16:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/106960.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 14 Apr 2005 21:41:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Thu, 14 Apr 2005 21:41:28 GMT]]></title><description><![CDATA[<p><strong>A. Organizational and Policy Issues.</strong></p>
<ol start="0">
<li>Don't sweat the small stuff. (Or: Know what not to standardize.).</li>
<li>Compile cleanly at high warning levels.</li>
<li>Use an automated build system.</li>
<li>Use a version control system.</li>
<li>Invest in code reviews.</li>
</ol>
<p><strong>B. Design Style.</strong></p>
<ol start="5">
<li>Give one entity one cohesive responsibility.</li>
<li>Correctness, simplicity, and clarity come first.</li>
<li>Know when and how to code for scalability.</li>
<li>Don't optimize prematurely.</li>
<li>Don't pessimize prematurely.</li>
<li>Minimize global and shared data.</li>
<li>Hide information.</li>
<li>Know when and how to code for concurrency.</li>
<li>Ensure resources are owned by objects. Use explicit RAII and smart pointers.</li>
</ol>
<p><strong>C. Coding Style.</strong></p>
<ol start="14">
<li>Prefer compile- and link-time errors to run-time errors.</li>
<li>Use const proactively.</li>
<li>Avoid macros.</li>
<li>Avoid magic numbers.</li>
<li>Declare variables as locally as possible.</li>
<li>Always initialize variables.</li>
<li>Avoid long functions. Avoid deep nesting.</li>
<li>Avoid initialization dependencies across compilation units.</li>
<li>Minimize definitional dependencies. Avoid cyclic dependencies.</li>
<li>Make header files self-sufficient.</li>
<li>Always write internal #include guards. Never write external #include guards.</li>
</ol>
<p><strong>D. Functions and Operators.</strong></p>
<ol start="25">
<li>Take parameters appropriately by value, (smart) pointer, or reference.</li>
<li>Preserve natural semantics for overloaded operators.</li>
<li>Prefer the canonical forms of arithmetic and assignment operators.</li>
<li>Prefer the canonical form of ++ and --. Prefer calling the prefix forms.</li>
<li>Consider overloading to avoid implicit type conversions.</li>
<li>Avoid overloading &amp;&amp;, ||, or , (comma)</li>
<li>Don't write code that depends on the order of evaluation of functionarguments.</li>
</ol>
<p><strong>E. Class Design and Inheritance.</strong></p>
<ol start="32">
<li>Be clear what kind of class you're writing.</li>
<li>Prefer minimal classes to monolithic classes.</li>
<li>Prefer composition to inheritance.</li>
<li>Avoid inheriting from classes that were not designed to be base classes.</li>
<li>Prefer providing abstract interfaces.</li>
<li>Public inheritance is substitutability. Inherit, not to reuse, but to be reused.</li>
<li>Practice safe overriding.</li>
<li>Consider making virtual functions nonpublic, and public functions nonvirtual.</li>
<li>Avoid providing implicit conversions.</li>
<li>Make data members private, except in behaviorless aggregates (C-stylestructs).</li>
<li>Don't give away your internals.</li>
<li>Pimpl judiciously.</li>
<li>Prefer writing nonmember nonfriend functions.</li>
<li>Always provide new and delete together.</li>
<li>If you provide any class-specific new, provide all of the standard forms (plain, in-place, and nothrow).</li>
</ol>
<p><strong>F. Construction, Destruction, and Copying.</strong></p>
<ol start="47">
<li>Define and initialize member variables in the same order.</li>
<li>Prefer initialization to assignment in constructors.</li>
<li>Avoid calling virtual functions in constructors and destructors.</li>
<li>Make base class destructors public and virtual, or protected and nonvirtual.</li>
<li>Destructors, deallocation, and swap never fail.</li>
<li>Copy and destroy consistently.</li>
<li>Explicitly enable or disable copying.</li>
<li>Avoid slicing. Consider Clone instead of copying in base classes.</li>
<li>Prefer the canonical form of assignment.</li>
<li>Whenever it makes sense, provide a no-fail swap (and provide it correctly).</li>
</ol>
<p><strong>G. Namespaces and Modules.</strong></p>
<ol start="57">
<li>Keep a type and its nonmember function interface in the same namespace.</li>
<li>Keep types and functions in separate namespaces unless they're specifically intended to work together.</li>
<li>Don't write namespace usings in a header file or before an #include.</li>
<li>Avoid allocating and deallocating memory in different modules.</li>
<li>Don't define entities with linkage in a header file.</li>
<li>Don't allow exceptions to propagate across module boundaries.</li>
<li>Use sufficiently portable types in a module's interface.</li>
<li>Blend static and dynamic polymorphism judiciously.</li>
<li>Customize intentionally and explicitly.</li>
<li>Don't specialize function templates.</li>
<li>Don't write unintentionally nongeneric code.</li>
</ol>
<p><strong>H. Templates and Genericity.</strong></p>
<ol start="68">
<li>Assert liberally to document internal assumptions and invariants.</li>
<li>Establish a rational error handling policy, and follow it strictly.</li>
<li>Distinguish between errors and non-errors.</li>
<li>Design and write error-safe code.</li>
<li>Prefer to use exceptions to report errors.</li>
<li>Throw by value, catch by reference.</li>
<li>Report, handle, and translate errors appropriately.</li>
<li>Avoid exception specifications.</li>
</ol>
<p><strong>I. Error Handling and Exceptions.</strong></p>
<ol start="76">
<li>Use vector by default. Otherwise, choose an appropriate container.</li>
<li>Use vector and string instead of arrays.</li>
<li>Use vector (and string::c_str) to exchange data with non-C++ APIs.</li>
<li>Store only values and smart pointers in containers.</li>
<li>Prefer push_back to other ways of expanding a sequence.</li>
<li>Prefer range operations to single-element operations.</li>
<li>Use the accepted idioms to really shrink capacity and really erase elements.</li>
</ol>
<p><strong>J. STL: Containers.</strong></p>
<ol start="83">
<li>Use a checked STL implementation.</li>
<li>Prefer algorithm calls to handwritten loops.</li>
<li>Use the right STL search algorithm.</li>
<li>Use the right STL sort algorithm.</li>
<li>Make predicates pure functions.</li>
<li>Prefer function objects over functions as algorithm and comparer arguments.</li>
<li>Write function objects correctly.</li>
</ol>
<p><strong>K. Type Safety.</strong></p>
<ol start="90">
<li>Avoid type switching; prefer polymorphism.</li>
<li>Rely on types, not on representations.</li>
<li>Avoid using reinterpret_cast.</li>
<li>Avoid using static_cast on pointers.</li>
<li>Avoid casting away const.</li>
<li>Don't use C-style casts.</li>
<li>Don't memcpy or memcmp non-PODs.</li>
<li>Don't use unions to reinterpret representation.</li>
<li>Don't use varargs (ellipsis).</li>
<li>Don't use invalid objects. Don't use unsafe functions.</li>
<li>Don't treat arrays polymorphically.</li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/post/767127</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767127</guid><dc:creator><![CDATA[Ich bin Gott]]></dc:creator><pubDate>Thu, 14 Apr 2005 21:41:28 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Thu, 14 Apr 2005 21:44:50 GMT]]></title><description><![CDATA[<pre><code>Use vector (and string::c_str) to exchange data with non-C++ APIs.
</code></pre>
<p>???</p>
<p>[Edit]<br />
Meine Glaskugel meint eigentlich !!!<br />
[/Edit]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767128</guid><dc:creator><![CDATA[Green_Ghost]]></dc:creator><pubDate>Thu, 14 Apr 2005 21:44:50 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 05:54:48 GMT]]></title><description><![CDATA[<p>@Gott<br />
1. Sind das 101 Regeln.<br />
2. Sollte man auch einen verweiß auf die Quelle dieser Regeln hinsetzen<br />
In diesem Fall ist das:<br />
[ C++ Coding Standards 101 (rules, guidelines and best practise) - Herb Sutter, Andrei Alexandrescu ]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767204</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767204</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Fri, 15 Apr 2005 05:54:48 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 07:48:06 GMT]]></title><description><![CDATA[<p>eViLiSSiMo schrieb:</p>
<blockquote>
<p>1. Sind das 101 Regeln.</p>
</blockquote>
<p>Jaja, dabei war es doch logisch, dss die bei der 0 anfangen zu zählen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767264</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767264</guid><dc:creator><![CDATA[Slin]]></dc:creator><pubDate>Fri, 15 Apr 2005 07:48:06 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 11:23:52 GMT]]></title><description><![CDATA[<p>eViLiSSiMo schrieb:</p>
<blockquote>
<p>2. Sollte man auch einen verweiß auf die Quelle dieser Regeln hinsetzen<br />
In diesem Fall ist das:<br />
[ C++ Coding Standards 101 (rules, guidelines and best practise) - Herb Sutter, Andrei Alexandrescu ]</p>
</blockquote>
<p>Stimmt!</p>
<p>btw. hatte das Buch gewonnen.... mit Unterschrift beider Autoren <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> sonst noch wer?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767430</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767430</guid><dc:creator><![CDATA[Heimwerkerking]]></dc:creator><pubDate>Fri, 15 Apr 2005 11:23:52 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 12:00:50 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">78) Use vector (and string::c_str) to exchange data with non-C++ APIs.
</code></pre>
<p>wie ist das gemeint,</p>
<p>Ist sowas legal:</p>
<pre><code class="language-cpp">vector&lt;char&gt; v(100);
strcpy(&amp;v[0], &quot;hallo&quot;);
</code></pre>
<p>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767455</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767455</guid><dc:creator><![CDATA[DrGreenthumb]]></dc:creator><pubDate>Fri, 15 Apr 2005 12:00:50 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 12:01:45 GMT]]></title><description><![CDATA[<p>ja klar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767456</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767456</guid><dc:creator><![CDATA[full ack]]></dc:creator><pubDate>Fri, 15 Apr 2005 12:01:45 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 13:28:14 GMT]]></title><description><![CDATA[<p>also so klar finde ich das nicht, aber gut zu wissen. danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767524</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767524</guid><dc:creator><![CDATA[DrGreenthumb]]></dc:creator><pubDate>Fri, 15 Apr 2005 13:28:14 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 13:35:29 GMT]]></title><description><![CDATA[<p>DrGreenthumb schrieb:</p>
<blockquote>
<p>also so klar finde ich das nicht, aber gut zu wissen. danke</p>
</blockquote>
<p>klar ist es, weil vector ja nur einen T* wrappt. und ein C String ist ja ein char*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767528</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767528</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Fri, 15 Apr 2005 13:35:29 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 13:38:38 GMT]]></title><description><![CDATA[<p>Und der Standart garantiert das der Speicher am Stück forliegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767532</guid><dc:creator><![CDATA[************]]></dc:creator><pubDate>Fri, 15 Apr 2005 13:38:38 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 14:20:59 GMT]]></title><description><![CDATA[<p>übersetze das mal ganze auf Deutsch bitte, sonst könnte es sein dass ich die anderen noobs erbarmungslos mit falschen Informationen bombardiere <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/767561</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767561</guid><dc:creator><![CDATA[xBlackKnightx]]></dc:creator><pubDate>Fri, 15 Apr 2005 14:20:59 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 14:36:03 GMT]]></title><description><![CDATA[<p>xBlackKnightx schrieb:</p>
<blockquote>
<p>übersetze das mal ganze auf Deutsch bitte, sonst könnte es sein dass ich die anderen noobs erbarmungslos mit falschen Informationen bombardiere <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Dann belehre Noobs einfach nur in den Themen von denen du Ahnung hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767573</guid><dc:creator><![CDATA[Walli]]></dc:creator><pubDate>Fri, 15 Apr 2005 14:36:03 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 14:36:57 GMT]]></title><description><![CDATA[<p>Walli schrieb:</p>
<blockquote>
<p>xBlackKnightx schrieb:</p>
<blockquote>
<p>übersetze das mal ganze auf Deutsch bitte, sonst könnte es sein dass ich die anderen noobs erbarmungslos mit falschen Informationen bombardiere <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Dann belehre Noobs einfach nur in den Themen von denen du Ahnung hast.</p>
</blockquote>
<p>also gar nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/767575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767575</guid><dc:creator><![CDATA[wahrheit]]></dc:creator><pubDate>Fri, 15 Apr 2005 14:36:57 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Fri, 15 Apr 2005 14:40:29 GMT]]></title><description><![CDATA[<p>wahrheit schrieb:</p>
<blockquote>
<p>Walli schrieb:</p>
<blockquote>
<p>xBlackKnightx schrieb:</p>
<blockquote>
<p>übersetze das mal ganze auf Deutsch bitte, sonst könnte es sein dass ich die anderen noobs erbarmungslos mit falschen Informationen bombardiere <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Dann belehre Noobs einfach nur in den Themen von denen du Ahnung hast.</p>
</blockquote>
<p>also gar nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
</blockquote>
<p>also doch übersetzen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/767578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/767578</guid><dc:creator><![CDATA[xBlackKnightx]]></dc:creator><pubDate>Fri, 15 Apr 2005 14:40:29 GMT</pubDate></item><item><title><![CDATA[Reply to 100 wichtige Regeln für C++ Programmierer on Tue, 16 Aug 2005 14:14:04 GMT]]></title><description><![CDATA[<p><strong>A. Organizational and Policy Issues.</strong></p>
<ol start="0">
<li>Don't sweat the small stuff. (Or: Know what not to standardize.).</li>
<li>Compile cleanly at high warning levels.</li>
<li>Use an automated build system.</li>
<li>Use a version control system.</li>
<li>Invest in code reviews.</li>
</ol>
<p><strong>B. Design Style.</strong></p>
<ol start="5">
<li>Give one entity one cohesive responsibility.</li>
<li>Correctness, simplicity, and clarity come first.</li>
<li>Know when and how to code for scalability.</li>
<li>Don't optimize prematurely.</li>
<li>Don't pessimize prematurely.</li>
<li>Minimize global and shared data.</li>
<li>Hide information.</li>
<li>Know when and how to code for concurrency.</li>
<li>Ensure resources are owned by objects. Use explicit RAII and smart pointers.</li>
</ol>
<p><strong>C. Coding Style.</strong></p>
<ol start="14">
<li>Prefer compile- and link-time errors to run-time errors.</li>
<li>Use const proactively.</li>
<li>Avoid macros.</li>
<li>Avoid magic numbers.</li>
<li>Declare variables as locally as possible.</li>
<li>Always initialize variables.</li>
<li>Avoid long functions. Avoid deep nesting.</li>
<li>Avoid initialization dependencies across compilation units.</li>
<li>Minimize definitional dependencies. Avoid cyclic dependencies.</li>
<li>Make header files self-sufficient.</li>
<li>Always write internal #include guards. Never write external #include guards.</li>
</ol>
<p><strong>D. Functions and Operators.</strong></p>
<ol start="25">
<li>Take parameters appropriately by value, (smart) pointer, or reference.</li>
<li>Preserve natural semantics for overloaded operators.</li>
<li>Prefer the canonical forms of arithmetic and assignment operators.</li>
<li>Prefer the canonical form of ++ and --. Prefer calling the prefix forms.</li>
<li>Consider overloading to avoid implicit type conversions.</li>
<li>Avoid overloading &amp;&amp;, ||, or , (comma)</li>
<li>Don't write code that depends on the order of evaluation of functionarguments.</li>
</ol>
<p><strong>E. Class Design and Inheritance.</strong></p>
<ol start="32">
<li>Be clear what kind of class you're writing.</li>
<li>Prefer minimal classes to monolithic classes.</li>
<li>Prefer composition to inheritance.</li>
<li>Avoid inheriting from classes that were not designed to be base classes.</li>
<li>Prefer providing abstract interfaces.</li>
<li>Public inheritance is substitutability. Inherit, not to reuse, but to be reused.</li>
<li>Practice safe overriding.</li>
<li>Consider making virtual functions nonpublic, and public functions nonvirtual.</li>
<li>Avoid providing implicit conversions.</li>
<li>Make data members private, except in behaviorless aggregates (C-stylestructs).</li>
<li>Don't give away your internals.</li>
<li>Pimpl judiciously.</li>
<li>Prefer writing nonmember nonfriend functions.</li>
<li>Always provide new and delete together.</li>
<li>If you provide any class-specific new, provide all of the standard forms (plain, in-place, and nothrow).</li>
</ol>
<p><strong>F. Construction, Destruction, and Copying.</strong></p>
<ol start="47">
<li>Define and initialize member variables in the same order.</li>
<li>Prefer initialization to assignment in constructors.</li>
<li>Avoid calling virtual functions in constructors and destructors.</li>
<li>Make base class destructors public and virtual, or protected and nonvirtual.</li>
<li>Destructors, deallocation, and swap never fail.</li>
<li>Copy and destroy consistently.</li>
<li>Explicitly enable or disable copying.</li>
<li>Avoid slicing. Consider Clone instead of copying in base classes.</li>
<li>Prefer the canonical form of assignment.</li>
<li>Whenever it makes sense, provide a no-fail swap (and provide it correctly).</li>
</ol>
<p><strong>G. Namespaces and Modules.</strong></p>
<ol start="57">
<li>Keep a type and its nonmember function interface in the same namespace.</li>
<li>Keep types and functions in separate namespaces unless they're specifically intended to work together.</li>
<li>Don't write namespace usings in a header file or before an #include.</li>
<li>Avoid allocating and deallocating memory in different modules.</li>
<li>Don't define entities with linkage in a header file.</li>
<li>Don't allow exceptions to propagate across module boundaries.</li>
<li>Use sufficiently portable types in a module's interface.</li>
<li>Blend static and dynamic polymorphism judiciously.</li>
<li>Customize intentionally and explicitly.</li>
<li>Don't specialize function templates.</li>
<li>Don't write unintentionally nongeneric code.</li>
</ol>
<p><strong>H. Templates and Genericity.</strong></p>
<ol start="68">
<li>Assert liberally to document internal assumptions and invariants.</li>
<li>Establish a rational error handling policy, and follow it strictly.</li>
<li>Distinguish between errors and non-errors.</li>
<li>Design and write error-safe code.</li>
<li>Prefer to use exceptions to report errors.</li>
<li>Throw by value, catch by reference.</li>
<li>Report, handle, and translate errors appropriately.</li>
<li>Avoid exception specifications.</li>
</ol>
<p><strong>I. Error Handling and Exceptions.</strong></p>
<ol start="76">
<li>Use vector by default. Otherwise, choose an appropriate container.</li>
<li>Use vector and string instead of arrays.</li>
<li>Use vector (and string::c_str) to exchange data with non-C++ APIs.</li>
<li>Store only values and smart pointers in containers.</li>
<li>Prefer push_back to other ways of expanding a sequence.</li>
<li>Prefer range operations to single-element operations.</li>
<li>Use the accepted idioms to really shrink capacity and really erase elements.</li>
</ol>
<p><strong>J. STL: Containers.</strong></p>
<ol start="83">
<li>Use a checked STL implementation.</li>
<li>Prefer algorithm calls to handwritten loops.</li>
<li>Use the right STL search algorithm.</li>
<li>Use the right STL sort algorithm.</li>
<li>Make predicates pure functions.</li>
<li>Prefer function objects over functions as algorithm and comparer arguments.</li>
<li>Write function objects correctly.</li>
</ol>
<p><strong>K. Type Safety.</strong></p>
<ol start="90">
<li>Avoid type switching; prefer polymorphism.</li>
<li>Rely on types, not on representations.</li>
<li>Avoid using reinterpret_cast.</li>
<li>Avoid using static_cast on pointers.</li>
<li>Avoid casting away const.</li>
<li>Don't use C-style casts.</li>
<li>Don't memcpy or memcmp non-PODs.</li>
<li>Don't use unions to reinterpret representation.</li>
<li>Don't use varargs (ellipsis).</li>
<li>Don't use invalid objects. Don't use unsafe functions.</li>
<li>Don't treat arrays polymorphically.</li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/post/853469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853469</guid><dc:creator><![CDATA[repost]]></dc:creator><pubDate>Tue, 16 Aug 2005 14:14:04 GMT</pubDate></item></channel></rss>