{"id":51,"date":"2007-01-11T16:37:15","date_gmt":"2007-01-11T14:37:15","guid":{"rendered":"http:\/\/appinf.com\/poco\/blog\/?p=51"},"modified":"2007-01-11T16:37:15","modified_gmt":"2007-01-11T14:37:15","slug":"bulletproofing-c-code","status":"publish","type":"post","link":"https:\/\/pocoproject.org\/blog\/?p=51","title":{"rendered":"Bulletproofing C++ Code"},"content":{"rendered":"<p>Sergei Sokolov <span class=\"greenBlurb\">examines interesting techniques <\/span><span class=\"greenBlurb\">at <a target=\"_blank\" href=\"http:\/\/www.ddj.com\/dept\/cpp\/196802351\">Dr. Dobbs Journal<\/a>, <\/span><span class=\"greenBlurb\">that improve the stability and reduce the risks of errors for C++ programming.<\/span><\/p>\n<p>Here a short summary.<\/p>\n<p><strong>Step 1. Use Static Analyis<\/strong><\/p>\n<blockquote>\n<ul>\n<li>Peer code reviews remain the best approach for finding code defects<\/li>\n<li>using a human brain to read and understand the code, looking for defects with a fresh eye<\/li>\n<li>about <a target=\"_blank\" href=\"http:\/\/www.cebase.org\/www\/resources\/reports\/usc\/usccse2001-515.pdf\">60 percent of defects<\/a> can be removed via code reviews<\/li>\n<li>automated static analysis effectively support this step<\/li>\n<li>two types of static analysis exists : pattern matching (based on coding practices or coding policy) and dataflow analysis<\/li>\n<li>Effective application of static analysis goes beyond buying the appropriate tools; it also requires the careful application and monitoring of processes<\/li>\n<\/ul>\n<\/blockquote>\n<p><strong>Step 2. Establish a  Reliable Regression Base<\/strong><\/p>\n<blockquote>\n<ul>\n<li>in average 25 percent of software defects are introduced while programmers are fixing and changing code during maintenance<\/li>\n<li>first create some regression tests before making any code changes<\/li>\n<li>There are two approaches to create such a regression test suite. Top-down by identifying the module-under-test&#8217;s high-level API and bottom-up by starting from the leaf-level functions and examine the internal paths.<\/li>\n<li>support this step by <a target=\"_blank\" href=\"http:\/\/cxxtest.sourceforge.net\">tools <\/a>capable auto-generating API tests and test coverage.<\/li>\n<li>Once the test suite is in place, its execution must be automated so that it can be run on a regular and frequent basis<\/li>\n<\/ul>\n<\/blockquote>\n<p>S<strong>tep 3. Develop Unit and Regression Tests<\/strong><\/p>\n<blockquote>\n<ul>\n<li>Once you begin writing code or fixing issues in existing code, there&#8217;s no excuse for neglecting to properly test the code you wrote<\/li>\n<li>If you have fixed a defect, tests have to be created to verify the fix<\/li>\n<\/ul>\n<\/blockquote>\n<p><strong>Step 4. Static Analysis and  Code Review<\/strong><\/p>\n<blockquote>\n<ul>\n<li>Once the new code passes all the checks, including a clean bill of health from static analysis and regression testing with sufficient coverage, it should be finalized by a team code review<\/li>\n<\/ul>\n<\/blockquote>\n<blockquote \/>\n","protected":false},"excerpt":{"rendered":"<p>Sergei Sokolov examines interesting techniques at Dr. Dobbs Journal, that improve the stability and reduce the risks of errors for C++ programming. Here a short summary. Step 1. Use Static Analyis Peer code reviews remain the best approach for finding code defects using a human brain to read and understand the code, looking for defects [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=51"}],"version-history":[{"count":0,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/51\/revisions"}],"wp:attachment":[{"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pocoproject.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}