SlideShare a Scribd company logo
1 of 56
Download to read offline
Leganés!
6-7 Febrero 2013!

David Gómez G.

@dgomezg

Measuring Code Quality: WTF/min
Code from the real world that could give you a stroke
and some advices to not replicate them.

Except where otherwise noted, this work is licensed under: http://creativecommons.org/licenses/by-nc-sa/3.0/
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

2
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Quality CODE
RELATED CONCEPTS

3
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

4

http://www.osnews.com/story/19266/WTFs_m
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

CODE SMELL
A surface indication
that usually
corresponds to a
deeper problem in the
system
Term coined by Kent Beck
5
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Some Misconceptions
You write code for a computer to read
You write code to be read by a developer maintaining your
code. The computer reads the compiled code
Writing smart code, you will improve performance
Developers spend most of the time writing code
Developers spend most of time reading code
6
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Some Misconceptions
You write code for a computer to read
You write code to be read by a developer maintaining your
code. The computer reads the compiled code
Writing smart code, you will improve performance
Developers spend most of the time writing code
Developers spend most of time reading code
6
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Some Misconceptions
You write code for a computer to read
You write code to be read by a developer maintaining your
code. The computer reads the compiled code
Writing smart code, you will improve performance
Developers spend most of the time writing code
Developers spend most of time reading code
6
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Some Misconceptions
You write code for a computer to read
You write code to be read by a developer maintaining your
code. The computer reads the compiled code
Writing smart code, you will improve performance
Developers spend most of the time writing code
Developers spend most of time reading code
6
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Examples of real code
from the real world

7
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

8
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

The following code
has been modified slightly
to protect anonymity
of authors
!

but always respect the original idea
(although it could be difficult to believe)
9
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

COMMENTS
Comments are useful, but

/*        */
Only if they add information
or if they explain the code

Don’t describe what the code is doing
Explain why (pre/post-conditions)

Use cases (for methods/types/functions)

10
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

COMMENTS: Unuseful info

@dgomezg

/*        */
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

COMMENTS: Unuseful info

/*        */
	 /**	
	
* Método get Disponibilidad.	
	
* 	
	
* @return Returns the disponibilidad.	
	
*/	
	 public String getDisponibilidad() {	

//
//

	 }

We will get back to the implementation detail	
More fun later
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

COMMENTS: Unuseful info

@dgomezg

/*        */
  
  
!
  
  
  
  
  
  
  
  

/**  Atributo  codCircuito.  */  
private  String  codCircuito;  

/**  
  *  Método  get  codCircuito.  
  *    
  *  @return  String  
  */  
public  String  getCodCircuito()  {  
   return  codCircuito;  
}  
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

COMMENTS:
Remember to sign your code

/*        */
////////////////////////Manuela  
Logger  log  =  LoggerFactory.getLogger(MyClass.class.getName());  
////////////////////////
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

COMMENTS:
A good marketing tool

/*        */
/** 	
* This method removes all selected files	
*
	
* Returns a jQuery collection of all affected elements.
*
	
* @name reset
	
* @type jQuery
	
* @author Daniel B. ( http://www.visit-my-web.com/) 	
*
	
*/ 	
reset: function(){
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

COMMENTS:
FOOL THE code READEr

@dgomezg

/*        */
//

Producto p = null;	
List prod = null;	
List listaElementos = new ArrayList();	
	
if (nElements > 80) {	
	 cmd.setOrden(Producto.SELECT_POR_TIPO);	
	 l = new ListParam();	
	 l.add(new Integer(idTipoProducto));	
l.add(new Integer(idCategoria));	

* for the trick to work out, keep the indentation
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Exceptions
Exceptions are just that: Exceptions
Catch only if you can handle it
Declare the exact type
Don’t use for:
Flow Control
State demarcation (other than Error)
17
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Exceptions: Simply retrowing
public  static  Class  cargaClase(java.lang.String  pnombreClase)  
                throws  ClassNotFoundException  {  
        ClassLoader  oloader  =  new  ClasesUtil().getClass()  
.getClassLoader();  
        try  {  
                return  oloader  !=  null  ?    
                   oloader.loadClass(pnombreClase)    
                   :  Class.forName(pnombreClase);  
        }  catch  (ClassNotFoundException  x)  {                        
                throw  x;  
        }  
}
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

Exceptions: NPE PARANOIA

@dgomezg

It’s better to check twice to avoid a NullPointerException
  
  
  

while  (session  !=  null)  {  
   numSessions++  ;  
   if  (session  !=  null)  {  
      ...  
}  
...  
}  
  
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Exceptions: NPE PARANOIA

It’s better to check twice to avoid a NullPointerException
	
	
	
	
	
	
	
	
	

while (session != null) {	
	 numSessions++ ;	
	 if (session != null) {	
	 	 //....	
	 } else {	
	 	 log.warn("Null session detected.” +	
“ Starting session Synchronization");	
	 	 //.... dead code follows...	
	 }	
}

extra points if
you add ‘dead code’ to the else block
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Exceptions: Flow Control
public  class  ProcesoTerminadoCorrectamenteException               
              extends  Exception  {  
!
}  

Man!
When a process which right ends is an exception…
That’s a good confidence in your system!
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

NAMING
Use descriptive names
Describe what a Class/function/method does,
not what it means
Describe what a variable/attribute holds
Don’t use abbreviations
Code for readability
22
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

NAMING: What does this method do?
        if(  p  !=  null){  
                applyBusinessLogic(p,estado,manager);  
        }

  
  
  
  

public  void  onButtonPressed(ActionEvent  e)  {  
   FormData  formData  =  parseFromEvent(e);  
   theAlgorithm(formData);  
}  

23
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

UnNecessary code
Developers should be lazy
Don’t write code you don’t need
Don’t repeat yourself

24
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

UnNecessary code:
Wrapping well-known APIs
public  static  String  substringBefore(String  str,String  separator)  {  
        return  (org.apache.commons.lang.StringUtils  
.substringBefore(str,  separator));  
}  

25
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

UnNecessary code:
Wrapping well-known APIs
  
  
  
  
  
  
  

public  String  getPropiedad(String  clave)  {  
   return  wrappedCacheAdmin.getProperty(clave);  
}  
  
public  void  setClaseAlgoritmo(String  clase)  {  
   wrappedCacheAdmin.setAlgorithmClass(clase);  
}  

26
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

UnNecessary code: Clever? Code
        /**  La  constante  CERO.  */  
        public  static  final  int  CERO=0;  
          
        /**  La  constante  UNO.  */  
        public  static  final  int  UNO=1;  
          
        /**  La  constante  DOS.  */  
        public  static  final  int  DOS=2;  
          
        /**  La  constante  TRES.  */  
        public  static  final  int  TRES=3;  

27
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

UnNecessary code: Clever? Code
Challenge:
Could you tell what will print the following code?
  

  

System.out.println(DOS  *  TRES);

28
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

2K Effect… We miss you!
NODO 1

!
# Planificacion Procesos Batch
# (Formato ss mm hh dd MM yyyy)
NODO 3
#
cron.sync=0 00 15 * * ? !
# Planificacion Procesos Batch
cron.download=0 00 23 * * ? 2030
NODO 4
# (Formato ss mm hh dd MM yyyy)
cron.reports=0 00 23 * * ? 2030
!
#
!
cron.sync=0 00 16 * * ?
# Planificacion Procesos Batch
cron.download=0 00 03 * * ? 2030
# (Formato ss mm hh dd MM yyyy)
cron.reports=0 00 03 * * ? 2030
#
cron.sync=0 00 12 * * ?
cron.download=0 00 12 * * 2030
cron.reports=0 00 12 * * 2030

29
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

UnNecessary code: SOP
Introducing SOP: String Oriented Programming
	
	
	
	
	
	
	
	
	
	

/**	
* Método get Disponibilidad.	
* 	
* @return Returns the disponibilidad.	
*/	
public String getDisponibilidad() {	
	 if (numeroPuestos == 0)	
	 	 return "No";	
	 else return "Si";	
}
30
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

UnNecessary code:
TAKING ADVICE TOO SERIOUSLY
String concatenation in Java is not recommended.
Use StringBuffer or StringBuilder instead
StringBuffer hql = 	
new StringBuffer(	
"select distinct config from Config config ");	
	 Query query = session.createQuery(hql.toString()) ;	

Don’t push the recommendations to the limits!!!

31
Leganés!
6-7 Febrero 2014

@dgomezg

Measuring Code Quality: WTF/min

UnNecessary code:
The indentation MADNESS
        
        
        
        
        
        
        
        
        
        
        
        
          ]  
   });  
});  

  
  
  
  
  
  
  
  
  
  
  
},  

  
  
  
  
  
  
  
  
  
  
}  

  
  
  
  
  
  
  
  
  
]  

  
  
  
  
  
  
  
  
}  

  
  
  
  
  
  
  
}  

     
     
     
     
     
      }  
});  

     
     
     
     
});  

            }  
      });  
   }  
}  

32
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

DESIGN PRICIPLES

33
Leganés!
6-7 Febrero 2014

@dgomezg

Measuring Code Quality: WTF/min

K IS S
EEP

T

IMPLE

TUPID!
34
Leganés!
6-7 Febrero 2014

@dgomezg

Measuring Code Quality: WTF/min

D R Y
on’t

epeat

ourself
35
Leganés!
6-7 Febrero 2014

@dgomezg

Measuring Code Quality: WTF/min

S OC
eparation

F

oncerns
36
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

I:I

@dgomezg

!
!
!
!
!

SEPARATION OF CONCERNS
DON’T REPEAT YOURSELF
37
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

ENSURING CODE QUALITY:
THE QUALITY CYCLE

38
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Default Quality Cycle

39
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Add Intermediate Quality Checks

40
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Automate Intermediate Checks

41
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Measure with tools

42
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Define Business Key Indicators

43
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Define Alarms

44
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Get a Dashboard

45
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Added Value: keeping everybody happy

46
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

SOME FINAL ADVICES

47
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Read! Keep your brain healthy
Clean Code:
Robert Martin (@unclebob)

48
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

No Monkeys, No Lizards
Be concious, be consequent

www.adictosaltrabajo.com/detalle-­‐noticia.php?noticia=356

49
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

THe Software RUSTING principle
The software degrades slowly and slightly as
time passes…
Sometimes is not slowly neither slightly!!

50
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

The boy scout rule
Try and leave this world a little
better than you found it, and when
your turn comes to die you can die
happy in feeling that at any rate
you have not wasted your time but
have done your best.
Robert Stephenson Smyth Baden-Powell
51
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Always code as if the
person who ends up
maintaining your code is
a violent psychopath who
knows where you live.
John F. Woods, September 1991

52
Leganés!
6-7 Febrero 2014

Measuring Code Quality: WTF/min

@dgomezg

Always code as if the
person who ends up
maintaining your code is
a violent psychopath who
knows where you live.
John F. Woods, September 1991
////////////////////////Manuela  
Logger  log  =  LogFactory.getLogger(MyClass.class.getName());  
////////////////////////
53

More Related Content

What's hot

Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)
Peter Kofler
 
Code Review
Code ReviewCode Review
Code Review
Ravi Raj
 
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
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
Lim Chanmann
 
The Brutal Refactoring Game (2013)
The Brutal Refactoring Game (2013)The Brutal Refactoring Game (2013)
The Brutal Refactoring Game (2013)
Peter Kofler
 

What's hot (20)

Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)Concepts of Functional Programming for Java Brains (2010)
Concepts of Functional Programming for Java Brains (2010)
 
TDD refresher
TDD refresherTDD refresher
TDD refresher
 
TDD = bra design?
TDD = bra design?TDD = bra design?
TDD = bra design?
 
Designing Test Cases for the Gilded Rose Kata (2013)
Designing Test Cases for the Gilded Rose Kata (2013)Designing Test Cases for the Gilded Rose Kata (2013)
Designing Test Cases for the Gilded Rose Kata (2013)
 
Tdd
TddTdd
Tdd
 
Tdd practices
Tdd practicesTdd practices
Tdd practices
 
Tdd
TddTdd
Tdd
 
Code Review
Code ReviewCode Review
Code Review
 
TDD CrashCourse Part2: TDD
TDD CrashCourse Part2: TDDTDD CrashCourse Part2: TDD
TDD CrashCourse Part2: TDD
 
Euro python 2015 writing quality code
Euro python 2015   writing quality codeEuro python 2015   writing quality code
Euro python 2015 writing quality code
 
Tdd
TddTdd
Tdd
 
Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)
 
TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018
 
Test driven development(tdd)
Test driven development(tdd)Test driven development(tdd)
Test driven development(tdd)
 
Test drive on driven development process
Test drive on driven development processTest drive on driven development process
Test drive on driven development process
 
Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
The Brutal Refactoring Game (2013)
The Brutal Refactoring Game (2013)The Brutal Refactoring Game (2013)
The Brutal Refactoring Game (2013)
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
 
Outside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDDOutside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDD
 

Viewers also liked

Viewers also liked (15)

Agile code quality metrics
Agile code quality metricsAgile code quality metrics
Agile code quality metrics
 
Measuring the Code Quality Using Software Metrics
Measuring the Code Quality Using Software MetricsMeasuring the Code Quality Using Software Metrics
Measuring the Code Quality Using Software Metrics
 
How we git - commit policy and code review
How we git - commit policy and code reviewHow we git - commit policy and code review
How we git - commit policy and code review
 
Code Quality Assurance
Code Quality AssuranceCode Quality Assurance
Code Quality Assurance
 
Code Quality Analysis
Code Quality AnalysisCode Quality Analysis
Code Quality Analysis
 
Code Quality Learn, Measure And Organize Awareness
Code Quality   Learn, Measure And Organize AwarenessCode Quality   Learn, Measure And Organize Awareness
Code Quality Learn, Measure And Organize Awareness
 
Managing code quality with SonarQube - Radu Vunvulea
Managing code quality with SonarQube - Radu VunvuleaManaging code quality with SonarQube - Radu Vunvulea
Managing code quality with SonarQube - Radu Vunvulea
 
User-Perceived Source Code Quality Estimation based on Static Analysis Metrics
User-Perceived Source Code Quality Estimation based on Static Analysis MetricsUser-Perceived Source Code Quality Estimation based on Static Analysis Metrics
User-Perceived Source Code Quality Estimation based on Static Analysis Metrics
 
Code quality as a built-in process
Code quality as a built-in processCode quality as a built-in process
Code quality as a built-in process
 
SonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code QualitySonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code Quality
 
Code quality
Code qualityCode quality
Code quality
 
Python - code quality and production monitoring
Python - code quality and production monitoringPython - code quality and production monitoring
Python - code quality and production monitoring
 
Measure and Improve code quality. Using automation.
Measure and Improve code quality.  Using automation.Measure and Improve code quality.  Using automation.
Measure and Improve code quality. Using automation.
 
Aspects Of Code Quality meetup
Aspects Of Code Quality   meetupAspects Of Code Quality   meetup
Aspects Of Code Quality meetup
 
Le pilotage par les tests
Le pilotage par les testsLe pilotage par les tests
Le pilotage par les tests
 

Similar to Measuring Code Quality in WTF/min.

Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
David Gómez García
 
Save time by applying clean code principles
Save time by applying clean code principlesSave time by applying clean code principles
Save time by applying clean code principles
Edorian
 
Good code, Bad Code
Good code, Bad CodeGood code, Bad Code
Good code, Bad Code
josedasilva
 
CICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your MindCICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your Mind
ciconf
 
Effective codereview | Dave Liddament | CODEiD
Effective codereview | Dave Liddament | CODEiDEffective codereview | Dave Liddament | CODEiD
Effective codereview | Dave Liddament | CODEiD
CODEiD PHP Community
 
180 daraga cpp course session-1
180 daraga cpp course session-1180 daraga cpp course session-1
180 daraga cpp course session-1
Moustafa Ghoniem
 

Similar to Measuring Code Quality in WTF/min. (20)

Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
 
Wtf per lineofcode
Wtf per lineofcodeWtf per lineofcode
Wtf per lineofcode
 
BDD with Behat
BDD with BehatBDD with Behat
BDD with Behat
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8
 
Save time by applying clean code principles
Save time by applying clean code principlesSave time by applying clean code principles
Save time by applying clean code principles
 
No more dead kittens - Clean Code
No more dead kittens - Clean CodeNo more dead kittens - Clean Code
No more dead kittens - Clean Code
 
Good code, Bad Code
Good code, Bad CodeGood code, Bad Code
Good code, Bad Code
 
VVV validation and linting tool
VVV validation and linting toolVVV validation and linting tool
VVV validation and linting tool
 
CICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your MindCICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your Mind
 
Effective codereview | Dave Liddament | CODEiD
Effective codereview | Dave Liddament | CODEiDEffective codereview | Dave Liddament | CODEiD
Effective codereview | Dave Liddament | CODEiD
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
Web backdoors attacks, evasion, detection
Web backdoors   attacks, evasion, detectionWeb backdoors   attacks, evasion, detection
Web backdoors attacks, evasion, detection
 
Code Igniter Code Sniffer
Code Igniter  Code SnifferCode Igniter  Code Sniffer
Code Igniter Code Sniffer
 
Better watch your apps - MJ Keith
Better watch your apps - MJ KeithBetter watch your apps - MJ Keith
Better watch your apps - MJ Keith
 
Treat Your Unit Tests As Production Code - DARGO - Amadeus - Soirée du Test L...
Treat Your Unit Tests As Production Code - DARGO - Amadeus - Soirée du Test L...Treat Your Unit Tests As Production Code - DARGO - Amadeus - Soirée du Test L...
Treat Your Unit Tests As Production Code - DARGO - Amadeus - Soirée du Test L...
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
 
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
APIdays Paris 2019 - API Descriptions as Product Code by Phil Sturgeon, Stopl...
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
 
No Programmer Is an Island
No Programmer Is an IslandNo Programmer Is an Island
No Programmer Is an Island
 
180 daraga cpp course session-1
180 daraga cpp course session-1180 daraga cpp course session-1
180 daraga cpp course session-1
 

More from David Gómez García

More from David Gómez García (20)

Leverage CompletableFutures to handle async queries. DevNexus 2022
Leverage CompletableFutures to handle async queries. DevNexus 2022Leverage CompletableFutures to handle async queries. DevNexus 2022
Leverage CompletableFutures to handle async queries. DevNexus 2022
 
Building Modular monliths that could scale to microservices (only if they nee...
Building Modular monliths that could scale to microservices (only if they nee...Building Modular monliths that could scale to microservices (only if they nee...
Building Modular monliths that could scale to microservices (only if they nee...
 
Building modular monoliths that could scale to microservices (only if they ne...
Building modular monoliths that could scale to microservices (only if they ne...Building modular monoliths that could scale to microservices (only if they ne...
Building modular monoliths that could scale to microservices (only if they ne...
 
Leveraging Completable Futures to handle your query results Asynchrhonously
Leveraging Completable Futures to handle your query results AsynchrhonouslyLeveraging Completable Futures to handle your query results Asynchrhonously
Leveraging Completable Futures to handle your query results Asynchrhonously
 
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
Builiding Modular monoliths that can scale to microservices. JBCNConf 2021
 
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integrationCdm mil-18 - hypermedia ap is for headless platforms and data integration
Cdm mil-18 - hypermedia ap is for headless platforms and data integration
 
What's in a community like Liferay's
What's in a community like Liferay'sWhat's in a community like Liferay's
What's in a community like Liferay's
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
 
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTRT3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
 
Managing user's data with Spring Session
Managing user's data with Spring SessionManaging user's data with Spring Session
Managing user's data with Spring Session
 
Parallel streams in java 8
Parallel streams in java 8Parallel streams in java 8
Parallel streams in java 8
 
Construccion de proyectos con gradle
Construccion de proyectos con gradleConstruccion de proyectos con gradle
Construccion de proyectos con gradle
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Spring4 whats up doc?
Spring4 whats up doc?Spring4 whats up doc?
Spring4 whats up doc?
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
 
El poder del creador de Software. Entre la ingeniería y la artesanía
El poder del creador de Software. Entre la ingeniería y la artesaníaEl poder del creador de Software. Entre la ingeniería y la artesanía
El poder del creador de Software. Entre la ingeniería y la artesanía
 
Geo-SentimentZ
Geo-SentimentZGeo-SentimentZ
Geo-SentimentZ
 
HDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript ScriptingHDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript Scripting
 
A real systemwithjms-rest-protobuf-mongodb
A real systemwithjms-rest-protobuf-mongodbA real systemwithjms-rest-protobuf-mongodb
A real systemwithjms-rest-protobuf-mongodb
 
Spring Data y Mongo DB en un proyecto Real
Spring Data y Mongo DB en un proyecto RealSpring Data y Mongo DB en un proyecto Real
Spring Data y Mongo DB en un proyecto Real
 

Recently uploaded

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Measuring Code Quality in WTF/min.

  • 1. Leganés! 6-7 Febrero 2013! David Gómez G. @dgomezg Measuring Code Quality: WTF/min Code from the real world that could give you a stroke and some advices to not replicate them. Except where otherwise noted, this work is licensed under: http://creativecommons.org/licenses/by-nc-sa/3.0/
  • 2. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg 2
  • 3. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Quality CODE RELATED CONCEPTS 3
  • 4. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg 4 http://www.osnews.com/story/19266/WTFs_m
  • 5. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg CODE SMELL A surface indication that usually corresponds to a deeper problem in the system Term coined by Kent Beck 5
  • 6. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Some Misconceptions You write code for a computer to read You write code to be read by a developer maintaining your code. The computer reads the compiled code Writing smart code, you will improve performance Developers spend most of the time writing code Developers spend most of time reading code 6
  • 7. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Some Misconceptions You write code for a computer to read You write code to be read by a developer maintaining your code. The computer reads the compiled code Writing smart code, you will improve performance Developers spend most of the time writing code Developers spend most of time reading code 6
  • 8. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Some Misconceptions You write code for a computer to read You write code to be read by a developer maintaining your code. The computer reads the compiled code Writing smart code, you will improve performance Developers spend most of the time writing code Developers spend most of time reading code 6
  • 9. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Some Misconceptions You write code for a computer to read You write code to be read by a developer maintaining your code. The computer reads the compiled code Writing smart code, you will improve performance Developers spend most of the time writing code Developers spend most of time reading code 6
  • 10. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Examples of real code from the real world 7
  • 11. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg 8
  • 12. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg The following code has been modified slightly to protect anonymity of authors ! but always respect the original idea (although it could be difficult to believe) 9
  • 13. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg COMMENTS Comments are useful, but /*        */ Only if they add information or if they explain the code Don’t describe what the code is doing Explain why (pre/post-conditions) Use cases (for methods/types/functions) 10
  • 14. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min COMMENTS: Unuseful info @dgomezg /*        */
  • 15. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg COMMENTS: Unuseful info /*        */ /** * Método get Disponibilidad. * * @return Returns the disponibilidad. */ public String getDisponibilidad() { // // } We will get back to the implementation detail More fun later
  • 16. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min COMMENTS: Unuseful info @dgomezg /*        */     !                 /**  Atributo  codCircuito.  */   private  String  codCircuito;   /**    *  Método  get  codCircuito.    *      *  @return  String    */   public  String  getCodCircuito()  {     return  codCircuito;   }  
  • 17. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg COMMENTS: Remember to sign your code /*        */ ////////////////////////Manuela   Logger  log  =  LoggerFactory.getLogger(MyClass.class.getName());   ////////////////////////
  • 18. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg COMMENTS: A good marketing tool /*        */ /** * This method removes all selected files * * Returns a jQuery collection of all affected elements. * * @name reset * @type jQuery * @author Daniel B. ( http://www.visit-my-web.com/) * */ reset: function(){
  • 19. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min COMMENTS: FOOL THE code READEr @dgomezg /*        */ // Producto p = null; List prod = null; List listaElementos = new ArrayList(); if (nElements > 80) { cmd.setOrden(Producto.SELECT_POR_TIPO); l = new ListParam(); l.add(new Integer(idTipoProducto)); l.add(new Integer(idCategoria)); * for the trick to work out, keep the indentation
  • 20. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Exceptions Exceptions are just that: Exceptions Catch only if you can handle it Declare the exact type Don’t use for: Flow Control State demarcation (other than Error) 17
  • 21. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Exceptions: Simply retrowing public  static  Class  cargaClase(java.lang.String  pnombreClase)                  throws  ClassNotFoundException  {          ClassLoader  oloader  =  new  ClasesUtil().getClass()   .getClassLoader();          try  {                  return  oloader  !=  null  ?                       oloader.loadClass(pnombreClase)                       :  Class.forName(pnombreClase);          }  catch  (ClassNotFoundException  x)  {                                        throw  x;          }   }
  • 22. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min Exceptions: NPE PARANOIA @dgomezg It’s better to check twice to avoid a NullPointerException       while  (session  !=  null)  {     numSessions++  ;     if  (session  !=  null)  {       ...   }   ...   }    
  • 23. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Exceptions: NPE PARANOIA It’s better to check twice to avoid a NullPointerException while (session != null) { numSessions++ ; if (session != null) { //.... } else { log.warn("Null session detected.” + “ Starting session Synchronization"); //.... dead code follows... } } extra points if you add ‘dead code’ to the else block
  • 24. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Exceptions: Flow Control public  class  ProcesoTerminadoCorrectamenteException                            extends  Exception  {   ! }   Man! When a process which right ends is an exception… That’s a good confidence in your system!
  • 25. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg NAMING Use descriptive names Describe what a Class/function/method does, not what it means Describe what a variable/attribute holds Don’t use abbreviations Code for readability 22
  • 26. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg NAMING: What does this method do?        if(  p  !=  null){                  applyBusinessLogic(p,estado,manager);          }         public  void  onButtonPressed(ActionEvent  e)  {     FormData  formData  =  parseFromEvent(e);     theAlgorithm(formData);   }   23
  • 27. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg UnNecessary code Developers should be lazy Don’t write code you don’t need Don’t repeat yourself 24
  • 28. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg UnNecessary code: Wrapping well-known APIs public  static  String  substringBefore(String  str,String  separator)  {          return  (org.apache.commons.lang.StringUtils   .substringBefore(str,  separator));   }   25
  • 29. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg UnNecessary code: Wrapping well-known APIs               public  String  getPropiedad(String  clave)  {     return  wrappedCacheAdmin.getProperty(clave);   }     public  void  setClaseAlgoritmo(String  clase)  {     wrappedCacheAdmin.setAlgorithmClass(clase);   }   26
  • 30. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg UnNecessary code: Clever? Code        /**  La  constante  CERO.  */          public  static  final  int  CERO=0;                    /**  La  constante  UNO.  */          public  static  final  int  UNO=1;                    /**  La  constante  DOS.  */          public  static  final  int  DOS=2;                    /**  La  constante  TRES.  */          public  static  final  int  TRES=3;   27
  • 31. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg UnNecessary code: Clever? Code Challenge: Could you tell what will print the following code?     System.out.println(DOS  *  TRES); 28
  • 32. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg 2K Effect… We miss you! NODO 1 ! # Planificacion Procesos Batch # (Formato ss mm hh dd MM yyyy) NODO 3 # cron.sync=0 00 15 * * ? ! # Planificacion Procesos Batch cron.download=0 00 23 * * ? 2030 NODO 4 # (Formato ss mm hh dd MM yyyy) cron.reports=0 00 23 * * ? 2030 ! # ! cron.sync=0 00 16 * * ? # Planificacion Procesos Batch cron.download=0 00 03 * * ? 2030 # (Formato ss mm hh dd MM yyyy) cron.reports=0 00 03 * * ? 2030 # cron.sync=0 00 12 * * ? cron.download=0 00 12 * * 2030 cron.reports=0 00 12 * * 2030 29
  • 33. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg UnNecessary code: SOP Introducing SOP: String Oriented Programming /** * Método get Disponibilidad. * * @return Returns the disponibilidad. */ public String getDisponibilidad() { if (numeroPuestos == 0) return "No"; else return "Si"; } 30
  • 34. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg UnNecessary code: TAKING ADVICE TOO SERIOUSLY String concatenation in Java is not recommended. Use StringBuffer or StringBuilder instead StringBuffer hql = new StringBuffer( "select distinct config from Config config "); Query query = session.createQuery(hql.toString()) ; Don’t push the recommendations to the limits!!! 31
  • 35. Leganés! 6-7 Febrero 2014 @dgomezg Measuring Code Quality: WTF/min UnNecessary code: The indentation MADNESS                                                                                  ]     });   });                         },                       }                     ]                   }                 }                            }   });                   });            }       });     }   }   32
  • 36. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg DESIGN PRICIPLES 33
  • 37. Leganés! 6-7 Febrero 2014 @dgomezg Measuring Code Quality: WTF/min K IS S EEP T IMPLE TUPID! 34
  • 38. Leganés! 6-7 Febrero 2014 @dgomezg Measuring Code Quality: WTF/min D R Y on’t epeat ourself 35
  • 39. Leganés! 6-7 Febrero 2014 @dgomezg Measuring Code Quality: WTF/min S OC eparation F oncerns 36
  • 40. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min I:I @dgomezg ! ! ! ! ! SEPARATION OF CONCERNS DON’T REPEAT YOURSELF 37
  • 41. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg ENSURING CODE QUALITY: THE QUALITY CYCLE 38
  • 42. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Default Quality Cycle 39
  • 43. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Add Intermediate Quality Checks 40
  • 44. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Automate Intermediate Checks 41
  • 45. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Measure with tools 42
  • 46. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Define Business Key Indicators 43
  • 47. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Define Alarms 44
  • 48. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Get a Dashboard 45
  • 49. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Added Value: keeping everybody happy 46
  • 50. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg SOME FINAL ADVICES 47
  • 51. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Read! Keep your brain healthy Clean Code: Robert Martin (@unclebob) 48
  • 52. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg No Monkeys, No Lizards Be concious, be consequent www.adictosaltrabajo.com/detalle-­‐noticia.php?noticia=356 49
  • 53. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg THe Software RUSTING principle The software degrades slowly and slightly as time passes… Sometimes is not slowly neither slightly!! 50
  • 54. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg The boy scout rule Try and leave this world a little better than you found it, and when your turn comes to die you can die happy in feeling that at any rate you have not wasted your time but have done your best. Robert Stephenson Smyth Baden-Powell 51
  • 55. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live. John F. Woods, September 1991 52
  • 56. Leganés! 6-7 Febrero 2014 Measuring Code Quality: WTF/min @dgomezg Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live. John F. Woods, September 1991 ////////////////////////Manuela   Logger  log  =  LogFactory.getLogger(MyClass.class.getName());   //////////////////////// 53