
{"id":1723,"date":"2015-05-20T17:42:51","date_gmt":"2015-05-20T17:42:51","guid":{"rendered":"http:\/\/www.codergears.com\/Blog\/?p=1723"},"modified":"2015-05-22T14:14:39","modified_gmt":"2015-05-22T14:14:39","slug":"basic-steps-to-follow-before-contributing-to-a-c-project","status":"publish","type":"post","link":"https:\/\/codergears.com\/Blog\/?p=1723","title":{"rendered":"Basic steps to follow before contributing to a C++ project."},"content":{"rendered":"<p>Before contributing effectively to\u00a0a C++ project , it&#8217;s recommended to take a tour in the existing code base, and identify some of its \u00a0design and implementation choices. Indeed your contribution must be coherent with the existing source code.<\/p>\n<p>Here are some basic steps to follow before contribute to a C++ project:<br \/>\n<!--more--><\/p>\n<p><strong>1-Build<\/strong><\/p>\n<p>Before going further, the first step is to build\u00a0\u00a0the project, it&#8217;s an obivious task for some projects but it could be a headache for other ones. If the build is very complicated, it&#8217;s recommended to well document it or create one entry point script to build the project.<\/p>\n<p>Every\u00a0\u00a0C++ developer should know the basics of preprocessing, compilation and linking, there are many web resources to explain these phases. Indeed many\u00a0 C++ beginner developers spent many hours to understand why a code does not compile or link, and they could win a lot of time if they dedicate only few hours to understand how the build phase works.<\/p>\n<p><strong>2-Debug<\/strong><\/p>\n<p>Debugging is your first friend to understand how a code works. You must ensure that you can debug your project without problem. Furthermore it&#8217;s recommended to master some advanced\u00a0debug techniques to gain many hours when resolving a bug or try to understand the behavior of a specific source code.<\/p>\n<p><strong>3-Identify the paradigms used<\/strong><\/p>\n<p><span style=\"color: #555555;\">C++ is a multi paradigm language and it&#8217;s very important to know for a defined project which paradigm is mostly used. Indeed each one has its specificities and a developer must master some basic concepts of the paradigm used before study the project code base.\u00a0<\/span><\/p>\n<p>For generics don&#8217;t hesitate to discover the static polymorphism,\u00a0<a href=\"http:\/\/accu.org\/index.php\/journals\/442\">Traits\u00a0<\/a><span style=\"color: #333333;\">and\u00a0<\/span><a href=\"http:\/\/en.wikipedia.org\/wiki\/Policy-based_design\">Policy-based design<\/a><span style=\"color: #333333;\">\u00a0techniques and f<\/span>or OOP\u00a0 it&#8217;s recommended to master \u00a0virtual methods, polymorphism and inheritence.<\/p>\n<p><strong>4-Identify the style used<\/strong><\/p>\n<p>Before adding your contribution, it&#8217;s recommended to know which coding\u00a0style is used, sometimes it&#8217;s documented like the <a href=\"https:\/\/google-styleguide.googlecode.com\/svn\/trunk\/cppguide.html\">google style guide<\/a>, but usually it&#8217;s not the case and you have to read some source code files to check:<\/p>\n<ul>\n<li>Naming convention.<\/li>\n<li>Code formatting.<\/li>\n<li>Is smart pointers used instead of raw pointers?<\/li>\n<li>Comment style.<\/li>\n<li>Uses of exceptions.<\/li>\n<li>Include guard technique used.<\/li>\n<li>&#8230;&#8230;<\/li>\n<\/ul>\n<p>The goal is to still coherent with the existing code base. You can be assisted by\u00a0<a href=\"http:\/\/www.cppdepend.com\">CppDepend<\/a> and its CQLinq query language \u00a0to ensure that some coding rules are not violated.<\/p>\n<p><strong>5-Identify the C++ frameworks and libraries used by the project<\/strong><\/p>\n<p><span style=\"color: #333333;\">Using frameworks and libraries accelerate the development. It&#8217;s very important to know which libraries\u00a0are used and most important what perimeter they\u00a0cover. It helps to avoid reinventing the wheel or use another library.<\/span><\/p>\n<p>If you have to use a feature from a\u00a0third party library, the best way is to search in the existing code where it&#8217;s\u00a0used. It could be used differently in many places, and in such\u00a0case prefer the code snippet from the well tested source code.<\/p>\n<p><strong>6-Identify a use case and debug it<\/strong><\/p>\n<p>The best way to have a concrete idea about the project design and implementation choices\u00a0is to study a use case from the front to the back. For that you can add breakpoints in some \u00a0places and debug it step by step to identify:<\/p>\n<ul>\n<li>The use case workflow.<\/li>\n<li>How the different levels communicate between them.<\/li>\n<li>The design patterns used if any.<\/li>\n<li>How the third party libraries are used, and check if the code is highly coupled with them or not by using abstract classes.<\/li>\n<\/ul>\n<p><strong>7-Master the basics of \u00a0the version control system used<\/strong><\/p>\n<p>The version control system\u00a0is the management of source changes . Changes are usually identified by a number or letter code, termed the &#8220;revision number&#8221;, &#8220;revision level&#8221;, or simply &#8220;revision&#8221;. \u00a0Revisions can be compared, restored, and with some types of files, merged.<\/p>\n<p>Many version control systems exist like Git, SVN, CVS, ClearCase\u00a0and it&#8217;s recommended to master their basics, many times the beginner developers did some big mistakes when managing their source code.and it impact a lot their contributions.<\/p>\n<p><strong>And don&#8217;t forget to Communicate with the team<\/strong><\/p>\n<p>Communicate with the other project developers is the easy way to accelerate your integration into a specific project and ensure a good quality for your contributions. Don&#8217;t hesitate to talk with them about the build process, the style used, the third party libraries used and so on. However avoid to disturb them each 5 min.<\/p>\n<p><strong>\u00a0Summary<\/strong><\/p>\n<p>Be coherent with the existing source code is very important to let it more readable and maintainable. Before contributing \u00a0it&#8217;s better to\u00a0discover how the existing code is designed and implemented and even it could take few days it will improve the quality of\u00a0your contributions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before contributing effectively to\u00a0a C++ project , it&#8217;s recommended to take a tour in the existing code base, and identify some of its \u00a0design and implementation choices. Indeed your contribution must be coherent with the existing source code. Here are some basic steps to follow before contribute to a C++ project:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1723","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/1723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1723"}],"version-history":[{"count":38,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/1723\/revisions"}],"predecessor-version":[{"id":1761,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/1723\/revisions\/1761"}],"wp:attachment":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}