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
 
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)Peter Kofler
 
Tdd practices
Tdd practicesTdd practices
Tdd practicesaxykim00
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 
TDD CrashCourse Part2: TDD
TDD CrashCourse Part2: TDDTDD CrashCourse Part2: TDD
TDD CrashCourse Part2: TDDDavid Rodenas
 
Euro python 2015 writing quality code
Euro python 2015   writing quality codeEuro python 2015   writing quality code
Euro python 2015 writing quality coderadek_j
 
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 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 2018Paulo Clavijo
 
Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Peter Kofler
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven DevelopmentLim Chanmann
 
The Brutal Refactoring Game (2013)
The Brutal Refactoring Game (2013)The Brutal Refactoring Game (2013)
The Brutal Refactoring Game (2013)Peter Kofler
 
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)Peter Kofler
 
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 TDDPeter 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

Agile code quality metrics
Agile code quality metricsAgile code quality metrics
Agile code quality metricsGil Nahmias
 
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 MetricsGeetha Anjali
 
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 reviewRuben Tan
 
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 AwarenessJaibeer Malik
 
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 VunvuleaITSpark Community
 
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 MetricsISSEL
 
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 processElad Maimon
 
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 QualityLarry Nung
 
Code quality
Code qualityCode quality
Code qualityProvectus
 
Python - code quality and production monitoring
Python - code quality and production monitoringPython - code quality and production monitoring
Python - code quality and production monitoringDavid Melamed
 
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.Vladimir Korolev
 

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
 
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 8Wim Godden
 
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 principlesEdorian
 
No more dead kittens - Clean Code
No more dead kittens - Clean CodeNo more dead kittens - Clean Code
No more dead kittens - Clean CodeYves Hoppe
 
Good code, Bad Code
Good code, Bad CodeGood code, Bad Code
Good code, Bad Codejosedasilva
 
VVV validation and linting tool
VVV validation and linting toolVVV validation and linting tool
VVV validation and linting toolMikko Ohtamaa
 
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 Mindciconf
 
Effective codereview | Dave Liddament | CODEiD
Effective codereview | Dave Liddament | CODEiDEffective codereview | Dave Liddament | CODEiD
Effective codereview | Dave Liddament | CODEiDCODEiD PHP Community
 
Code Igniter Code Sniffer
Code Igniter  Code SnifferCode Igniter  Code Sniffer
Code Igniter Code SnifferAlbert Rosa
 
Better watch your apps - MJ Keith
Better watch your apps - MJ KeithBetter watch your apps - MJ Keith
Better watch your apps - MJ Keithm j
 
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...TelecomValley
 
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 StitchMongoDB
 
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...apidays
 
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 PignataroSteven Pignataro
 
No Programmer Is an Island
No Programmer Is an IslandNo Programmer Is an Island
No Programmer Is an IslandJimmy Sieben
 
180 daraga cpp course session-1
180 daraga cpp course session-1180 daraga cpp course session-1
180 daraga cpp course session-1Moustafa 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

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 2022David Gómez García
 
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...David Gómez García
 
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...David Gómez García
 
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 AsynchrhonouslyDavid Gómez García
 
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 2021David Gómez García
 
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 integrationDavid Gómez García
 
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'sDavid Gómez García
 
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 modularidadDavid Gómez García
 
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 HDTRDavid Gómez García
 
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 SessionDavid Gómez García
 
Construccion de proyectos con gradle
Construccion de proyectos con gradleConstruccion de proyectos con gradle
Construccion de proyectos con gradleDavid Gómez García
 
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.David Gómez García
 
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íaDavid Gómez García
 
HDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript ScriptingHDTR images with Photoshop Javascript Scripting
HDTR images with Photoshop Javascript ScriptingDavid Gómez García
 
A real systemwithjms-rest-protobuf-mongodb
A real systemwithjms-rest-protobuf-mongodbA real systemwithjms-rest-protobuf-mongodb
A real systemwithjms-rest-protobuf-mongodbDavid Gómez García
 
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 RealDavid 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

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

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