User Tools

Site Tools


a_development_chain_to_build_reliable_software

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
a_development_chain_to_build_reliable_software [2015/12/16 18:23]
sgripon [Resources]
a_development_chain_to_build_reliable_software [2016/04/16 11:20] (current)
sgripon
Line 1: Line 1:
 ====== A development chain to build reliable software ====== ====== A development chain to build reliable software ======
 +~~socialite~~
  
 Automation is a really important point to build reliable software. There are many tools available to do the job, and most of them are open-source. Automation is a really important point to build reliable software. There are many tools available to do the job, and most of them are open-source.
Line 12: Line 13:
   * It can build your software 24 hours a day   * It can build your software 24 hours a day
   * It can build a software for each modification of your source code   * It can build a software for each modification of your source code
 +
 +{{::​jenkins.png |}}
  
 The standard steps you should do on the continuous integration tool: The standard steps you should do on the continuous integration tool:
Line 29: Line 32:
  
 While peer code review is necessary for software changes, doing part of the job with a tool help saving time and increase quality. There are several tools on the market for static source code analysis and they incredibly find many defects developers have left, sometimes because they were junior developers, sometimes because the algorithm is complex and the defect was not obvious. While peer code review is necessary for software changes, doing part of the job with a tool help saving time and increase quality. There are several tools on the market for static source code analysis and they incredibly find many defects developers have left, sometimes because they were junior developers, sometimes because the algorithm is complex and the defect was not obvious.
 +
 +{{ ::​coverity.jpg?​400|}}
  
 One of the most important point to check when evaluating this kind of tool is the rate of false-positive. If the rate is too high, your developers will spend precious time to analyze defects that are not real problems. However, a 0 false-positive rate is probably not possible. It the tool produces 0 false-positive,​ I can guess that it also finds very few number of defects. Moreover, it is important to analyze false-positives;​ often they are linked to complex source code that even a human will have trouble to analyze. That is why some will advice to also fix all false-positive defects: it simplifies the source code and help developers to fully understand what the program does. One of the most important point to check when evaluating this kind of tool is the rate of false-positive. If the rate is too high, your developers will spend precious time to analyze defects that are not real problems. However, a 0 false-positive rate is probably not possible. It the tool produces 0 false-positive,​ I can guess that it also finds very few number of defects. Moreover, it is important to analyze false-positives;​ often they are linked to complex source code that even a human will have trouble to analyze. That is why some will advice to also fix all false-positive defects: it simplifies the source code and help developers to fully understand what the program does.
Line 38: Line 43:
  
 //​Website//:​ https://​www.reviewboard.org/​ //​Website//:​ https://​www.reviewboard.org/​
 +
 +{{ ::​reviewboard.png|}}
 +
 +When managing a software project with several teams and many developers scattered over several sites, it is sometimes difficult to maintain code quality: it is necessary to ensure that the changes are correct technically and fit coding rules and software architecture. For this, we need to communicate between remote developers on a proposed change or correction of a defect. It often begins to achieve this by setting up a process based on patch files sent by email. There are several drawbacks to this method:
 +
 +  * The emails may not be archived and published for all developers
 +  * The comments on the product code are inserted in the email, and differently from one developer to another which does not facilitate the resumption of work by another person
 +  * The process is completely manual which increases the risk of errors and omissions.
 +  * It is difficult to produce indicators on code reviews.
 +
 +One way to overcome these problems is to use a tool that will allow to automate certain tasks, centralize code reviews and standardize them. ReviewBoard,​ an open source web tool does this job quite well.
 +
 +ReviewBoard can be used in two ways: by reviewing pre-delivery and post-delivery. I use both approaches: pre-delivery when there is an identified risk of the delivery or doubt on the solution. In post-delivery to systematically inform the maintainer of a module that delivery was made in its scope and thus avoid unpleasant surprises that would have been discovered much later with more damage.
 +==== Using pre-delivery reviews ====
 +
 +In this mode, the developer who wants to submit a code change will generate a patch file and create manually a new code review request in ReviewBoard. This is done simply by downloading the file to the web interface of the tool. A review request is created: then just add in the list of those reviewers to whom we want to submit the change. At the publication of the request, the reviewer will be automatically notified by email of the review request.
 +
 +==== Using post-delivery reviews ====
 +
 +ReviewBoard provides a useful command line tool to publish new code review requests. Thus, it is very easy to integrate into a continuous integration system (eg Jenkins) creating a review request for each new modification detected in the code base. In practice, I created a script that allows developer to specify who subscribes to a particular piece of code: the developer is then automatically added as a reviewer to the new code review when a change was delivered in his scope and it will be notified by email of the change.
 +
 +==== Code review ====
 +
 +Once the code review request has been created, it is possible to annotate the modified code line by line or by grouping lines. It is also possible to make general comments on the change. Then the reviewer publishes the review and the author of the request is then notified by email. It can then fix his delivery and resubmit a change: the process then starts again.
 +
 +In terms of ergonomics, the tool is again well done: the ReviewBoard code viewer supports syntax coloring and reading the code and modifications is nice: we can really concentrate on the review without having to worry about the tool.
 +===== Coding Standard Checking =====
 +
 +It is important to define a coding standard for developing your software. And it is also really important to check the coding standard is applied.
 +
 +To avoid doing too much checking by peer reviews, which is time consuming, it is easy to integrate home made scripts in the continuous integration system. Most of the time, using simple regular expressions in the source code can help to find errors.
 +
 +I also experienced successfully this kind of script to verify that the software architecture is not broken. For example, if yout software is organized as a Model-View-Controller pattern (MVC) and models, views and controllers are in different folders, it is easy to check that there is no view file included in a model file.
  
 ===== Improving the Quality of legacy source code ===== ===== Improving the Quality of legacy source code =====
Line 49: Line 87:
   - When there are no remaining warnings, modify your compilation flags to consider warnings as errors   - When there are no remaining warnings, modify your compilation flags to consider warnings as errors
  
-Communicate this rule to your developers, and you will see the number of warnings decrease until reaching ​O. It can take several weeks or several month, depending of your software.+Communicate this rule to your developers, and you will see the number of warnings decrease until reaching ​0. It can take several weeks or several month, depending of your software. 
 + 
 +**Share this page:** 
 + 
 +~~socialite~~
  
 ====== Resources ====== ====== Resources ======
  
-  * [[https://​www.usenix.org/​conference/​hotdep12/​workshop-program/​presentation/​holzmann|Mars Code]]: a very good conference by Gerard Holzmann from JPL at NASA. It deals with the software used to send Opportunity ​to Mars.+  * [[https://​www.usenix.org/​conference/​hotdep12/​workshop-program/​presentation/​holzmann|Mars Code]]: a very good conference by Gerard Holzmann from JPL at NASA. It deals with the software used to send the Curiosity rover to Mars.
   * [[http://​www.gamasutra.com/​view/​news/​128836/​InDepth_Static_Code_Analysis.php|In-Depth:​ Static Code Analysis]] by John Carmack.   * [[http://​www.gamasutra.com/​view/​news/​128836/​InDepth_Static_Code_Analysis.php|In-Depth:​ Static Code Analysis]] by John Carmack.
a_development_chain_to_build_reliable_software.1450286591.txt.gz · Last modified: 2015/12/16 18:23 by sgripon