SlideShare a Scribd company logo
1 of 15
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

More Related Content

What's hot

Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)
Peter Kofler
 
Code Retreat Graz, Austria 2013
Code Retreat Graz, Austria 2013Code Retreat Graz, Austria 2013
Code Retreat Graz, Austria 2013
Peter Kofler
 
Software Craftsmanship Journeyman Tour (2013)
Software Craftsmanship Journeyman Tour (2013)Software Craftsmanship Journeyman Tour (2013)
Software Craftsmanship Journeyman Tour (2013)
Peter Kofler
 

What's hot (20)

It's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecIt's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspec
 
Pair Programming (2015)
Pair Programming (2015)Pair Programming (2015)
Pair Programming (2015)
 
Infinum Android Talks #19 - Stop wasting time fixing bugs with TDD by Domagoj...
Infinum Android Talks #19 - Stop wasting time fixing bugs with TDD by Domagoj...Infinum Android Talks #19 - Stop wasting time fixing bugs with TDD by Domagoj...
Infinum Android Talks #19 - Stop wasting time fixing bugs with TDD by Domagoj...
 
Coding Dojo Object Calisthenics (2016)
Coding Dojo Object Calisthenics (2016)Coding Dojo Object Calisthenics (2016)
Coding Dojo Object Calisthenics (2016)
 
Javascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end DevsJavascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end Devs
 
Coding Dojo - Refactoring Tennis Kata
Coding Dojo - Refactoring Tennis KataCoding Dojo - Refactoring Tennis Kata
Coding Dojo - Refactoring Tennis Kata
 
Code Quality for a Fresh Start
Code Quality for a Fresh StartCode Quality for a Fresh Start
Code Quality for a Fresh Start
 
GDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran CanariaGDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran Canaria
 
Why I Love Ruby On Rails
Why I Love Ruby On RailsWhy I Love Ruby On Rails
Why I Love Ruby On Rails
 
BDD with the Cucumber
BDD with the CucumberBDD with the Cucumber
BDD with the Cucumber
 
Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)
 
Detangling Your JavaScript
Detangling Your JavaScriptDetangling Your JavaScript
Detangling Your JavaScript
 
TDD with RSpec
TDD with RSpecTDD with RSpec
TDD with RSpec
 
How to quickly add a safety net to a legacy codebase
How to quickly add a safety net to a legacy codebaseHow to quickly add a safety net to a legacy codebase
How to quickly add a safety net to a legacy codebase
 
Code Retreat Graz, Austria 2013
Code Retreat Graz, Austria 2013Code Retreat Graz, Austria 2013
Code Retreat Graz, Austria 2013
 
Brutal Coding Constraints (ITAKE 2017)
Brutal Coding Constraints (ITAKE 2017)Brutal Coding Constraints (ITAKE 2017)
Brutal Coding Constraints (ITAKE 2017)
 
TDD as if You Meant It (2013)
TDD as if You Meant It (2013)TDD as if You Meant It (2013)
TDD as if You Meant It (2013)
 
Integration of automation framework with ci tools
Integration of automation framework with ci toolsIntegration of automation framework with ci tools
Integration of automation framework with ci tools
 
Software Craftsmanship Journeyman Tour (2013)
Software Craftsmanship Journeyman Tour (2013)Software Craftsmanship Journeyman Tour (2013)
Software Craftsmanship Journeyman Tour (2013)
 
Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)
 

Similar to Code Quality Assurance

Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
Theo Jungeblut
 
Effective TDD - Less is more
Effective TDD - Less is moreEffective TDD - Less is more
Effective TDD - Less is more
Ben Lau
 

Similar to Code Quality Assurance (20)

You cant be agile if your code sucks
You cant be agile if your code sucksYou cant be agile if your code sucks
You cant be agile if your code sucks
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
 
Indy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-muleIndy meetup#7 effective unit-testing-mule
Indy meetup#7 effective unit-testing-mule
 
Clean Code Pt I
Clean Code Pt IClean Code Pt I
Clean Code Pt I
 
Gateway to Agile: XP and BDD
Gateway to Agile: XP and BDD Gateway to Agile: XP and BDD
Gateway to Agile: XP and BDD
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
 
Tdd!
Tdd!Tdd!
Tdd!
 
Clean application development (talk)
Clean application development (talk)Clean application development (talk)
Clean application development (talk)
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven Development
 
Software Quality without Testing
Software Quality without TestingSoftware Quality without Testing
Software Quality without Testing
 
Usable Software Design
Usable Software DesignUsable Software Design
Usable Software Design
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEAN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
 
Effective TDD - Less is more
Effective TDD - Less is moreEffective TDD - Less is more
Effective TDD - Less is more
 
An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1An Introduction To Software Development - Test Driven Development, Part 1
An Introduction To Software Development - Test Driven Development, Part 1
 
Test Driven Development and Automation
Test Driven Development and AutomationTest Driven Development and Automation
Test Driven Development and Automation
 
Tdd
TddTdd
Tdd
 
Software craftsmanship
Software craftsmanshipSoftware craftsmanship
Software craftsmanship
 
What designers can learn from (code) review
What designers can learn from (code) reviewWhat designers can learn from (code) review
What designers can learn from (code) review
 
Agile & Test Driven Development: The Ampersand Commerce Approach
Agile & Test Driven Development: The Ampersand Commerce ApproachAgile & Test Driven Development: The Ampersand Commerce Approach
Agile & Test Driven Development: The Ampersand Commerce Approach
 

More from Bart Blommaerts

More from Bart Blommaerts (17)

Cloud-Native Architecture
Cloud-Native ArchitectureCloud-Native Architecture
Cloud-Native Architecture
 
Innovation Without Asking Permission
Innovation Without Asking PermissionInnovation Without Asking Permission
Innovation Without Asking Permission
 
JavaDay 2017: 10 tips to become an awesome technical lead (v4)
JavaDay 2017: 10 tips to become an awesome technical lead (v4)JavaDay 2017: 10 tips to become an awesome technical lead (v4)
JavaDay 2017: 10 tips to become an awesome technical lead (v4)
 
JavaOne 2017: 10 tips to become an awesome Technical Lead (v3)
JavaOne 2017: 10 tips to become an awesome Technical Lead (v3)JavaOne 2017: 10 tips to become an awesome Technical Lead (v3)
JavaOne 2017: 10 tips to become an awesome Technical Lead (v3)
 
10 tips to become an awesome Technical Lead v2 (Devoxx PL)
10 tips to become an awesome Technical Lead v2 (Devoxx PL)10 tips to become an awesome Technical Lead v2 (Devoxx PL)
10 tips to become an awesome Technical Lead v2 (Devoxx PL)
 
10 tips to become an awesome technical lead
10 tips to become an awesome technical lead10 tips to become an awesome technical lead
10 tips to become an awesome technical lead
 
Pragmatic Architecture (SATURN 2017)
Pragmatic Architecture (SATURN 2017)Pragmatic Architecture (SATURN 2017)
Pragmatic Architecture (SATURN 2017)
 
Pragmatic Architecture, Today (v2)
Pragmatic Architecture, Today (v2)Pragmatic Architecture, Today (v2)
Pragmatic Architecture, Today (v2)
 
Serverless as a Collaborative Economy Enabler
Serverless as a Collaborative Economy EnablerServerless as a Collaborative Economy Enabler
Serverless as a Collaborative Economy Enabler
 
Pragmatic Architecture, Today.
Pragmatic Architecture, Today.Pragmatic Architecture, Today.
Pragmatic Architecture, Today.
 
The Serverless Cloud @ JAX London 2016
The Serverless Cloud @ JAX London 2016The Serverless Cloud @ JAX London 2016
The Serverless Cloud @ JAX London 2016
 
The Collaborative Economy
The Collaborative EconomyThe Collaborative Economy
The Collaborative Economy
 
JavaOne: Efficiently building and deploying microservices
JavaOne: Efficiently building and deploying microservicesJavaOne: Efficiently building and deploying microservices
JavaOne: Efficiently building and deploying microservices
 
e-IB Bouwstenen: Magda
e-IB Bouwstenen: Magdae-IB Bouwstenen: Magda
e-IB Bouwstenen: Magda
 
Developing applications for the cloud
Developing applications for the cloudDeveloping applications for the cloud
Developing applications for the cloud
 
Java security
Java securityJava security
Java security
 
HP Discover - Developing new applications for the cloud
HP Discover - Developing new applications for the cloudHP Discover - Developing new applications for the cloud
HP Discover - Developing new applications for the cloud
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

Code Quality Assurance

  • 1. 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
  • 2. 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
  • 3. Why do we need clean code? 3 HP Confidential Jan 2013
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. 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
  • 11. 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
  • 12. How do we measure clean code? • 12 Demo! HP Confidential Jan 2013
  • 13. 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
  • 15. THANKS FOR YOUR ATTENTION ©2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice