advertisement

Code Quality Assurance

43 %
57 %
advertisement
Information about Code Quality Assurance
Technology

Published on December 15, 2013

Author: BartBlommaerts

Source: slideshare.net

Description

Do's and don'ts regarding Code Quality Assurance. Presentation given to a technical Java audience.
advertisement

CODE QUALITY ASSURANCE Jan 15, 2013 Bart Blommaerts bart.blommaerts@hp.com EMEA NG Java & WEB: HP Belgium ©2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice

Agenda • Why do we need clean code? • What is clean code? • How do we write clean code? • How do we test clean code? • How do we measure clean code? • Disclaimer: clean code vs. great code • Q&A 2 HP Confidential Jan 2013

Why do we need clean code? 3 HP Confidential Jan 2013

Why do we need clean code? Objectives – Easy to read and understand – Unnecessary – Maintaining • and extending code is easier First step towards re-use! – Project • code and noise are removed lifecycle cost will be reduced Cost of owning a mess .. “Writing clean code is what you must do in order to call yourself a professional. There is no reasonable excuse for doing anything less than your best.” Robert C. Martin 4 HP Confidential Jan 2013

What is clean code? • • • • • • 5 HP Confidential Simple and direct Human readable Efficient No duplications: DRY Made for the problem Easy to enhance Jan 2013

How do we write clean code? • SRP: Single responsibility principle – – Stepdown Rule – • Do One Thing Restrict number of arguments (3 is a lot ..) Boy Scout Rule – – 6 Leave code better than you found it Don’t comment bad code, rewrite it HP Confidential Jan 2013

How do we write clean code? • Meaningful, self-explaining names – – • Purpose of a variable, class, method, .. Avoid disinformation (eg. lblUserName) Error Handling – – 7 Don’t return null – • Use exceptions rather then return codes Don’t pass null Expresses intent HP Confidential Jan 2013

How do we test clean code? • SRP: Single responsibility principle – • Boy Scout Rule – 8 Unit test enabler Add unit tests before refactoring HP Confidential Jan 2013

How do we test clean code? • Meaningful names – • Understand what to test Error Handling – @Test(expected=CleanCodeException.class) Fix a bug only once. Write Unit tests when fixing bugs! 9 HP Confidential Jan 2013

How do we measure clean code? • Sonar integration – • http://sonar.elabs.eds.com:9000/ Maven: <properties> <sonar.jdbc.url> jdbc:mysql://sonar.elabs.eds.com:3306/sonar?useUnicode=true&amp;characterEncoding=utf8 </sonar.jdbc.url> <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver> <sonar.jdbc.username>x</sonar.jdbc.username> <sonar.jdbc.password>x</sonar.jdbc.password> <sonar.host.url>http://sonar.elabs.eds.com:9000</sonar.host.url> </properties> 10 HP Confidential Jan 2013

How do we measure clean code? • Ant: <!-- Sonar properties --> <property name="sonar.jdbc.url" value="jdbc:mysql://sonar.elabs.eds.com:3306/sonar?useUnicode=true&amp;characterEncoding=utf8" /> <property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver" /> <property name="sonar.jdbc.username" value="x" /> <property name="sonar.jdbc.password" value="x" /> <property name="sonar.host.url" value="http://sonar.elabs.eds.com:9000" /> <!-- Sonar target --> <target name="sonar" depends="compile"> <sonar:sonar workDir="." key="be.vlaanderen.vip:xfire" version="02.00" xmlns:sonar="antlib:org.sonar.ant"> <sources> <path location="${project.dir.src}" /> </sources> </sonar:sonar> </target> <!-- Sonar task --> <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml"> <classpath> <fileset dir="${project.dir.lib}"> <include name="sonar-ant-task-1.0.jar" /> </fileset> </classpath> </taskdef> 11 HP Confidential Jan 2013

How do we measure clean code? • 12 Demo! HP Confidential Jan 2013

Disclaimer: clean code vs. great code • Primary goal: making it work • SRP – – • But: no methods with 1 line of code But: don’t write a huge amount of tiny classes Boy Scout Rule – 13 Don’t go overboard HP Confidential Jan 2013

Q& A http://www.osnews.com/comics 14 HP Confidential Jan 2013

THANKS FOR YOUR ATTENTION ©2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Standards and Guidelines for Quality Assurance in the ...

2 isbn 952-5539-04-0 (paperbound ) isbn 952-5539-05-9 (pdf) issn 1458-1051 ENQA report on Standards and Guidelines for Quality Assurance in the European
Read more

Assuring standards and quality - Quality Assurance Agency ...

Introducing the work of the Quality Assurance Agency to assure standards and quality in UK higher education
Read more

The PHP Quality Assurance Toolchain

PHP_Depend. pdepend can generate a large set of software metrics from a given code base. These values can be used to measure the quality of a software ...
Read more

Quality assurance - Wikipedia, the free encyclopedia

The terms "quality assurance" and "quality control" are often used interchangeably to refer to ways of ensuring the quality of a service or product.
Read more

Code Quality Assurance in Visual Studio 2005 (C#, VB.NET ...

An article about quality assurance options/tools in/for VS2005 for VB.NET and C# projects.; Author: Alexander Nowak; Updated: 10 Aug 2007; Section: Design ...
Read more

Assurance Code | ISEAL Alliance

The purpose of the new Assurance Code is to provide guidance for high quality assurance that supports sustainability and improves the effectiveness of ...
Read more

8 QUALITY ASSURANCE AND QUALITY CONTROL - IGES

Quality Assurance and Quality Control Chapter 8 8.2 IPCC Good Practice Guidance and Uncertainty Management in National Greenhouse Gas Inventories
Read more

Status | Drupal Quality Assurance

Drupal Quality Assurance. System status; Queue; Drupal 8.0.x; Drupal 7.x; Branch tests; Test log; Latest changes. So Long and Thanks for all the Tests. 1 ...
Read more

Improve Code Quality - msdn.microsoft.com

What is code quality? Correctness, maintainability, and even elegance are all involved in creating great code. However you define it, Visual Studio test ...
Read more