SlideShare a Scribd company logo
1 of 65
Download to read offline
How to improve
the quality of your
TYPO3 extensions
Christian Trabold
Mike Zaschka

2nd October 2010, TYPO3 Conference Frankfurt
Agenda

 What‘s the problem?
 High speed code reviews
 Tools that help you
 Questions & Answers
Dowloads & Feedback

 We provide links and further information on
 http://bit.ly/t3con10-qatalk
 We are listening to you on twitter
 #t3con10-qatalk
 Ask!
 It‘s okay to ask after each chapter and after the talk :)
 The installation instructions are available in our
 paper
Who are we?




http://www.flickr.com/photos/kevenlaw/2684465429/
About us

 Christian Trabold
 Senior Developer
 Web since 1999
 TYPO3 since 2004
 dkd since 2006
 Focus on quality assurance
 Author of TYPO3 Kochbuch, O‘Reilly
 E-Mail christian.trabold@dkd.de
 Twitter @ctrabold
About us

 Mike Zaschka
 Senior Developer
 TYPO3 since 2005
 Ruby/Rails since 2007
 dkd since 2008
 eMail mike.zaschka@dkd.de
 Twitter @mike_zaschka
What is our
problem?
We all want a perfect extension


 TYPO3 API




                          TYPO3
Security cookbook         coding standards
We all want a perfect extension




     BUT
High complexity




Nobody wants to touch it.
No documentation




Nobody understands it.
Different standard




Nobody can read it.
How do you
 monitor the quality
 of many extensions?
Doing high speed
reviews
Code Reviews
PHP Mess Detection
Copy & Paste Detection
CodeSniffer
Code Reviews

Quality assurance with talking.
C ODE REVIEWS

SUCK
"Most of the time you sit
next to a hairy, unfriendly
colleage and argue about
    line indentions..."
                     Mike




                       http://www.flickr.com/photos/octopushat/403730001/
And after a while
you don't see code anymore!

   class Example {{
    class Example {
     class Example
        private static $ID == 1;
         private static $ID = 1;
        private $title ==$ID
          private static "t3con";
                               1;
         private $title = "t3con";
          private $title   "t3con";
         /*
          /*
           /*
         // Some code II don't want to delete
          // Some code I don't want to delete
           // Some code    don't want to delete
         public function addNothing($content) {{
          public function addNothing($content) {
           public function addNothing($content)
              $content == "";
               $content = "";
                $content   "";
              return $content;
               return $content;
         }}     return $content;
         */}
          */
           */
         public function addYear($year) {{
          public function addYear($year) {
           public function addYear($year)
              return $this->title .. "" 2010";
               return $this->title . " 2010";
                return $this->title      2010";
         }}
   }}      }
     }
Downsides of code reviews

 You have to search for errors
 You have no time
 Most of the time you discuss less important
 things
 No sharing of knowledge
 I hate my colleagues syndrome


 Do code reviews really ensure quality?
Manual code reviews can cause serious
damage to your nerves!




            You might nd your colleagues
            dead in front of the computer!
         None of our developers was harmed for this presentation!
                                                  http://www.flickr.com/photos/jakub_hlavaty/2164581030/
Wouldn‘t it be nice...

If a code review could be automated?

         If I could see the aws before I review?

Is it a dream or could it be reality?
PHP Mess



Checks your code
against errors and aws.
PHP Mess Detection Rules


     Code size      Unused
                     code
    Complexity
    Code length




      Naming         Design
    Methods       Eval
    Variables     Inheritance
Use PHP Mess Detector

Use it on your console like this:
  $ phpmd . text codesize,unusedcode,naming



                    Report
                    format          Rulesets

          Source
           path
Example code

 class Example {
   private static $ID = 1;
   private $title = "t3con";

     /* An unused method */
     private function addNothing($content) {
         $content = "";
         return $content;
     }

     public function addYear($year) {
         return $this->title . " 2010";
     }

     public function add_year_2010($year) {
         return $this->title . " 2010";
     }
 }
Detecting the mess



$ phpmd example.php text codesize,unusedcode,naming

 example.php:4    Avoid   unused private fields such as '$ID'.
 example.php:4    Avoid   variables with short names like $ID
 example.php:8    Avoid   unused private methods such as 'addNothing'.
 example.php:13   Avoid   unused parameters such as '$year'.
 example.php:17   Avoid   unused parameters such as '$year'.
Fixing the code

class Example {
  private static $ID = 1;                // Not used / too short
  private $title = "t3con";

    /* An unused method */
    private function addNothing($content) {    // Not used
        $content = "";
        return $content;
    }

    public function addYear($year) {          // Not used
        return $this->title . " 2010";
    }

    public function add_year_2010($year) {    // Not used
        return $this->title . " 2010";
    }
}
Fixing the code

class Example {
  private $title = "t3con";

    public function addYear() {
        return $this->title . " 2010";
    }

    public function add_year_2010() {
        return $this->title . " 2010";
    }
}
Copy Paste



Checks your code
for duplicate code.
Duplicate code is not
a little something!
 Unnecessary complexity
 Issues in architecture
 Hard maintainable code
 Multiple changes
 Error prone
Back to the example code

class Example {
  private $title = "t3con";

    public function addYear() {
        return $this->title . " 2010";
    }

    public function add_year_2010() {
        return $this->title . " 2010";
    }
}
Detecting duplicate code

You use it on your console like this:
  $ phpcpd example.php

    Found 1 exact clones with 2 duplicated
    lines in 1 files:

      - example.php:5-6
        example.php:9-10
Fixing the code

class Example {
  private $title = "t3con";

    public function addYear() {
        return $this->title . " 2010";   // Duplicate code
    }

    public function add_year_2010() {
        return $this->title . " 2010";   // Duplicate code
    }
}
Fixing the code

class Example {
  private $title = "t3con";

    public function addYear() {
        return $this->add_year_2010();
    }

    public function add_year_2010() {
        return $this->title . " 2010";
    }
}
CodeSniffer



Checks your code
against a coding standard.
Why coding standards?

 Readable code for you...
 ... and for others too!
 Maintainable by others
 Stop wasting time on reformating the code
 No more arguing about line indentions
TYPO3 coding standards

 http://forge.typo3.org/projects/team-
 php_codesniffer
 Standards for:
   Naming
   Documentation
   Format
   Control structures
   and more...
Install CodeSniffer

The package can install like this:
  $ pear install PHP_CodeSniffer-alpha

Then we register the TYPO3 PEAR Channel, to get
the TYPO3 Coding Standard:
  $ pear channel-discover pear.typo3.org

After that you install the TYPO3 Coding Standard
like this:
  $ pear install typo3/PHPCS_TYPO3_SniffPool
  $ pear install typo3/PHPCS_TYPO3v4_Standard
Set default Standard and use it!

Set the default standard and default Tab-With:
  $ phpcs --config-set default_standard TYPO3v4
  $ phpcs --config-set tab_width 4

Now you can use the CodeSniffer on the console
for your TYPO3-Extensions:
  $ phpcs example.php
One more time our example code

class Example {
  private $title = "t3con";

     public function addYear() {
         return $this->add_year_2010();
     }

    public function add_year_2010() {
         return $this->title . " 2010";
     }
}
Run CodeSniffer

Use CodeSniffer on the console:
  $ phpcs example.php

  --------------------------------------------
  FOUND 5 ERROR(S) AFFECTING 4 LINE(S)
  --------------------------------------------

   3   |   ERROR   |   Missing class doc comment
   4   |   ERROR   |   Line indented incorrectly;…
   6   |   ERROR   |   Missing function doc comment
   9   |   ERROR   |   Missing function doc comment
   9   |   ERROR   |   Method name not camel caps
Fixing the code

                                         // Missing comment
class Example {
  private $title = "t3con";              // Wrong indention
                                         // Missing comment
    public function addYear() {
        return $this->add_year_2010();
    }
                                         // Missing comment
    public function add_year_2010() {    // Wrong naming
        return $this->title . " 2010";
    }
}
Fixing the code

/**
 * An example class.
 *
 * @author Jon Doe <john.doe@example.com>
 */
class Example {
    private $title = "t3con";

    /**
      * Just an example function.
      *
      * @return string Some example string
      */
    public function addYear() {
         return $this->addYear2010();
    }
    …
What developers often think:

       Torture and pain




                      http://www. ickr.com/photos/mhswde/2722217304/
What they really are:

    Freedom and fun




                        http://www. ickr.com/photos/davidspinks/4453498888/
Other usage options

  PHP Tool Integration - Plugin for eclipse
  http://www.phpsrc.org/
Automate checking

 Automate tasks you do often
 Use CPU power to help you
 On a regular basis or on each commit into your
 version control management system
 Get reports instead of creating them
 Use a continuous integration server like Hudson
 or CruiseControl
Get support from
the community
Register your extension at
http://forge.typo3.org/start/createProject
What is forge?

 Integrated social development platform for
 extension developers.
 Tools to streamline communication on projects
 SourceControl-Management
 Issue tracker
 Wiki
 NEW an integrated continuous integration server
 still in an early status but ready for some real
 world tests!
We do quality tests for you

 Providing reporting and code metrics
 on ci.typo3.org
 What is currently checked?
   PHP Mess Detection
   Copy Paste Detection


 Making code reviews quicker and more fun!
How do we solve
the „red-light“-shock?
What's next

 CodeSniffer
 phpUnit-Tests
 More slaves for Hudson for faster response


 Your ideas?
Conclusion
Stop digging through code.




          Start with an overview.

                      http://www. ickr.com/photos/69er/329057062/
Reports are a good start
for good quality.


                http://www. ickr.com/photos/ uzo/97673183/
Tell everybody
how to use the tools



   Most important: the youngsters!
                     http://www. ickr.com/photos/kevenlaw/2787879806/
Make it a movement




  Inspiring people to share
  even better with extensions of higher quality!
dkd
     design
     kommunikation
     development




thank you.

More Related Content

What's hot

Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHPDavid Stockton
 
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...Yi Tan
 
TWIG: the flexible, fast and secure template language for PHP
TWIG: the flexible, fast and secure template language for PHPTWIG: the flexible, fast and secure template language for PHP
TWIG: the flexible, fast and secure template language for PHPCesare D'Amico
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScriptT11 Sessions
 
Class 3 - PHP Functions
Class 3 - PHP FunctionsClass 3 - PHP Functions
Class 3 - PHP FunctionsAhmed Swilam
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5Jason Austin
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09Bastian Feder
 
Drupaljam xl 2019 presentation multilingualism makes better programmers
Drupaljam xl 2019 presentation   multilingualism makes better programmersDrupaljam xl 2019 presentation   multilingualism makes better programmers
Drupaljam xl 2019 presentation multilingualism makes better programmersAlexander Varwijk
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHPWim Godden
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the BeastBastian Feder
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - phpHung-yu Lin
 

What's hot (19)

Intermediate OOP in PHP
Intermediate OOP in PHPIntermediate OOP in PHP
Intermediate OOP in PHP
 
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...
Convention Generator - Yi’s Eclipse Monkey Scripts for Coding ActionScript in...
 
TWIG: the flexible, fast and secure template language for PHP
TWIG: the flexible, fast and secure template language for PHPTWIG: the flexible, fast and secure template language for PHP
TWIG: the flexible, fast and secure template language for PHP
 
Design patterns in PHP
Design patterns in PHPDesign patterns in PHP
Design patterns in PHP
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
 
Class 3 - PHP Functions
Class 3 - PHP FunctionsClass 3 - PHP Functions
Class 3 - PHP Functions
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
PHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERSPHP NOTES FOR BEGGINERS
PHP NOTES FOR BEGGINERS
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
 
SPL, not a bridge too far
SPL, not a bridge too farSPL, not a bridge too far
SPL, not a bridge too far
 
PHP variables
PHP  variablesPHP  variables
PHP variables
 
Magento code audit
Magento code auditMagento code audit
Magento code audit
 
The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09The Beauty And The Beast Php N W09
The Beauty And The Beast Php N W09
 
Drupaljam xl 2019 presentation multilingualism makes better programmers
Drupaljam xl 2019 presentation   multilingualism makes better programmersDrupaljam xl 2019 presentation   multilingualism makes better programmers
Drupaljam xl 2019 presentation multilingualism makes better programmers
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 
The Beauty and the Beast
The Beauty and the BeastThe Beauty and the Beast
The Beauty and the Beast
 
Cfphp Zce 01 Basics
Cfphp Zce 01 BasicsCfphp Zce 01 Basics
Cfphp Zce 01 Basics
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
 

Viewers also liked

Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Praguetomasbart
 
Salesforce1 Platform - Der schnellste Weg von der Idee zur App
Salesforce1 Platform - Der schnellste Weg von der Idee zur AppSalesforce1 Platform - Der schnellste Weg von der Idee zur App
Salesforce1 Platform - Der schnellste Weg von der Idee zur AppSalesforce Deutschland
 
Luncheon 2015-11-19 - Lessons Learned from Avid Life Media by Rob Davis
Luncheon 2015-11-19 - Lessons Learned from Avid Life Media by Rob DavisLuncheon 2015-11-19 - Lessons Learned from Avid Life Media by Rob Davis
Luncheon 2015-11-19 - Lessons Learned from Avid Life Media by Rob DavisNorth Texas Chapter of the ISSA
 
Lasiru Rukshan Willaracchchi CV
Lasiru Rukshan Willaracchchi CVLasiru Rukshan Willaracchchi CV
Lasiru Rukshan Willaracchchi CVlrwillarachchi
 
Workshop rapport - First edition
Workshop rapport - First editionWorkshop rapport - First edition
Workshop rapport - First editionTeoriogPraksis
 
مركز الدراسات الاندلسية بتلمسان Centre d'études andalouses de tlemcen
 مركز الدراسات الاندلسية بتلمسان Centre d'études andalouses de tlemcen مركز الدراسات الاندلسية بتلمسان Centre d'études andalouses de tlemcen
مركز الدراسات الاندلسية بتلمسان Centre d'études andalouses de tlemcenAbdelkader Benhaddou
 
Poveste De Succes.
Poveste De Succes.Poveste De Succes.
Poveste De Succes.guest7a1d88
 
Mayli Sepulveda Acceso A La Informacion Para La Incidencia Publica
Mayli Sepulveda   Acceso A La Informacion Para La Incidencia PublicaMayli Sepulveda   Acceso A La Informacion Para La Incidencia Publica
Mayli Sepulveda Acceso A La Informacion Para La Incidencia PublicaMarco Giuseppe Gomero
 
Companies
CompaniesCompanies
Companiesecsrdl
 
Print Vision Presentation (August 2008)
Print Vision Presentation (August 2008)Print Vision Presentation (August 2008)
Print Vision Presentation (August 2008)Jon Hansen
 
Viii Semana MatemáTica Ies Sierra Minera Alumnos
Viii Semana MatemáTica Ies Sierra Minera AlumnosViii Semana MatemáTica Ies Sierra Minera Alumnos
Viii Semana MatemáTica Ies Sierra Minera AlumnosDe Mates Na
 
Brave new world private banking
Brave new world private bankingBrave new world private banking
Brave new world private bankingJuris Cernavskis
 
Protagonistas II Guerra Mundial
Protagonistas II Guerra MundialProtagonistas II Guerra Mundial
Protagonistas II Guerra MundialJeanpado7
 
State of Pinax
State of PinaxState of Pinax
State of Pinaxjtauber
 
Gsx code two gsx final
Gsx code two gsx finalGsx code two gsx final
Gsx code two gsx finalGSX Solutions
 

Viewers also liked (20)

Themes
ThemesThemes
Themes
 
The Way to TYPO3 6.0
The Way to TYPO3 6.0The Way to TYPO3 6.0
The Way to TYPO3 6.0
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Salesforce1 Platform - Der schnellste Weg von der Idee zur App
Salesforce1 Platform - Der schnellste Weg von der Idee zur AppSalesforce1 Platform - Der schnellste Weg von der Idee zur App
Salesforce1 Platform - Der schnellste Weg von der Idee zur App
 
Luncheon 2015-11-19 - Lessons Learned from Avid Life Media by Rob Davis
Luncheon 2015-11-19 - Lessons Learned from Avid Life Media by Rob DavisLuncheon 2015-11-19 - Lessons Learned from Avid Life Media by Rob Davis
Luncheon 2015-11-19 - Lessons Learned from Avid Life Media by Rob Davis
 
Lasiru Rukshan Willaracchchi CV
Lasiru Rukshan Willaracchchi CVLasiru Rukshan Willaracchchi CV
Lasiru Rukshan Willaracchchi CV
 
Workshop rapport - First edition
Workshop rapport - First editionWorkshop rapport - First edition
Workshop rapport - First edition
 
مركز الدراسات الاندلسية بتلمسان Centre d'études andalouses de tlemcen
 مركز الدراسات الاندلسية بتلمسان Centre d'études andalouses de tlemcen مركز الدراسات الاندلسية بتلمسان Centre d'études andalouses de tlemcen
مركز الدراسات الاندلسية بتلمسان Centre d'études andalouses de tlemcen
 
Te lo cuento octubre 2011
Te lo cuento octubre 2011Te lo cuento octubre 2011
Te lo cuento octubre 2011
 
Poveste De Succes.
Poveste De Succes.Poveste De Succes.
Poveste De Succes.
 
Mayli Sepulveda Acceso A La Informacion Para La Incidencia Publica
Mayli Sepulveda   Acceso A La Informacion Para La Incidencia PublicaMayli Sepulveda   Acceso A La Informacion Para La Incidencia Publica
Mayli Sepulveda Acceso A La Informacion Para La Incidencia Publica
 
EL FUJIYAMA
EL FUJIYAMAEL FUJIYAMA
EL FUJIYAMA
 
Companies
CompaniesCompanies
Companies
 
Print Vision Presentation (August 2008)
Print Vision Presentation (August 2008)Print Vision Presentation (August 2008)
Print Vision Presentation (August 2008)
 
Viii Semana MatemáTica Ies Sierra Minera Alumnos
Viii Semana MatemáTica Ies Sierra Minera AlumnosViii Semana MatemáTica Ies Sierra Minera Alumnos
Viii Semana MatemáTica Ies Sierra Minera Alumnos
 
Brave new world private banking
Brave new world private bankingBrave new world private banking
Brave new world private banking
 
Protagonistas II Guerra Mundial
Protagonistas II Guerra MundialProtagonistas II Guerra Mundial
Protagonistas II Guerra Mundial
 
Regresion
RegresionRegresion
Regresion
 
State of Pinax
State of PinaxState of Pinax
State of Pinax
 
Gsx code two gsx final
Gsx code two gsx finalGsx code two gsx final
Gsx code two gsx final
 

Similar to How to improve the quality of your TYPO3 extensions

Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
TYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkTYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkChristian Trabold
 
Multilingualism makes better programmers
Multilingualism makes better programmersMultilingualism makes better programmers
Multilingualism makes better programmersAlexander Varwijk
 
Fluent Development with FLOW3 1.0
Fluent Development with FLOW3 1.0Fluent Development with FLOW3 1.0
Fluent Development with FLOW3 1.0Robert Lemke
 
Code Documentation. That ugly thing...
Code Documentation. That ugly thing...Code Documentation. That ugly thing...
Code Documentation. That ugly thing...Christos Manios
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
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
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Hugo Hamon
 
The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014Matthias Noback
 
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
 
Clean Code: Stop wasting my time
Clean Code: Stop wasting my timeClean Code: Stop wasting my time
Clean Code: Stop wasting my timeEdorian
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003R696
 
The Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumThe Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumMatthias Noback
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest UpdatesIftekhar Eather
 
The Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony BarcelonaThe Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony BarcelonaMatthias Noback
 

Similar to How to improve the quality of your TYPO3 extensions (20)

Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
TYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkTYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase framework
 
Multilingualism makes better programmers
Multilingualism makes better programmersMultilingualism makes better programmers
Multilingualism makes better programmers
 
appledoc_style
appledoc_styleappledoc_style
appledoc_style
 
Fluent Development with FLOW3 1.0
Fluent Development with FLOW3 1.0Fluent Development with FLOW3 1.0
Fluent Development with FLOW3 1.0
 
Code Documentation. That ugly thing...
Code Documentation. That ugly thing...Code Documentation. That ugly thing...
Code Documentation. That ugly thing...
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
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
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014
 
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
 
Clean Code: Stop wasting my time
Clean Code: Stop wasting my timeClean Code: Stop wasting my time
Clean Code: Stop wasting my time
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Clean code _v2003
 Clean code _v2003 Clean code _v2003
Clean code _v2003
 
The Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumThe Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup Belgium
 
Srgoc dotnet
Srgoc dotnetSrgoc dotnet
Srgoc dotnet
 
Django introduction
Django introductionDjango introduction
Django introduction
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
 
The Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony BarcelonaThe Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony Barcelona
 

More from Christian Trabold

DevOps Meetup Bangkok - Value Stream Mapping for Continuous Delivery
DevOps Meetup Bangkok - Value Stream Mapping for Continuous DeliveryDevOps Meetup Bangkok - Value Stream Mapping for Continuous Delivery
DevOps Meetup Bangkok - Value Stream Mapping for Continuous DeliveryChristian Trabold
 
DevOps Training - Ho Chi Minh City
DevOps Training - Ho Chi Minh CityDevOps Training - Ho Chi Minh City
DevOps Training - Ho Chi Minh CityChristian Trabold
 
30 developers and one Vagrant
30 developers and one Vagrant30 developers and one Vagrant
30 developers and one VagrantChristian Trabold
 
How to use code metrics to improve quality
How to use code metrics to improve qualityHow to use code metrics to improve quality
How to use code metrics to improve qualityChristian Trabold
 
Drei Dinge, die mich kürzlich inspiriert haben
Drei Dinge, die mich kürzlich inspiriert habenDrei Dinge, die mich kürzlich inspiriert haben
Drei Dinge, die mich kürzlich inspiriert habenChristian Trabold
 
Drei Dinge, die mich kürzlich inspiriert haben
Drei Dinge, die mich kürzlich inspiriert haben Drei Dinge, die mich kürzlich inspiriert haben
Drei Dinge, die mich kürzlich inspiriert haben Christian Trabold
 

More from Christian Trabold (8)

DevOps Meetup Bangkok - Value Stream Mapping for Continuous Delivery
DevOps Meetup Bangkok - Value Stream Mapping for Continuous DeliveryDevOps Meetup Bangkok - Value Stream Mapping for Continuous Delivery
DevOps Meetup Bangkok - Value Stream Mapping for Continuous Delivery
 
DevOps Training - Ho Chi Minh City
DevOps Training - Ho Chi Minh CityDevOps Training - Ho Chi Minh City
DevOps Training - Ho Chi Minh City
 
TYPO3 
Infrastructure
TYPO3 
InfrastructureTYPO3 
Infrastructure
TYPO3 
Infrastructure
 
30 developers and one Vagrant
30 developers and one Vagrant30 developers and one Vagrant
30 developers and one Vagrant
 
How to use code metrics to improve quality
How to use code metrics to improve qualityHow to use code metrics to improve quality
How to use code metrics to improve quality
 
Drei Dinge, die mich kürzlich inspiriert haben
Drei Dinge, die mich kürzlich inspiriert habenDrei Dinge, die mich kürzlich inspiriert haben
Drei Dinge, die mich kürzlich inspiriert haben
 
Drei Dinge, die mich kürzlich inspiriert haben
Drei Dinge, die mich kürzlich inspiriert haben Drei Dinge, die mich kürzlich inspiriert haben
Drei Dinge, die mich kürzlich inspiriert haben
 
How healthy is TYPO3?
How healthy is TYPO3?How healthy is TYPO3?
How healthy is TYPO3?
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
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
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
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
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
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
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 

How to improve the quality of your TYPO3 extensions

  • 1. How to improve the quality of your TYPO3 extensions Christian Trabold Mike Zaschka 2nd October 2010, TYPO3 Conference Frankfurt
  • 2. Agenda What‘s the problem? High speed code reviews Tools that help you Questions & Answers
  • 3. Dowloads & Feedback We provide links and further information on http://bit.ly/t3con10-qatalk We are listening to you on twitter #t3con10-qatalk Ask! It‘s okay to ask after each chapter and after the talk :) The installation instructions are available in our paper
  • 5. About us Christian Trabold Senior Developer Web since 1999 TYPO3 since 2004 dkd since 2006 Focus on quality assurance Author of TYPO3 Kochbuch, O‘Reilly E-Mail christian.trabold@dkd.de Twitter @ctrabold
  • 6. About us Mike Zaschka Senior Developer TYPO3 since 2005 Ruby/Rails since 2007 dkd since 2008 eMail mike.zaschka@dkd.de Twitter @mike_zaschka
  • 8. We all want a perfect extension TYPO3 API TYPO3 Security cookbook coding standards
  • 9. We all want a perfect extension BUT
  • 13. How do you monitor the quality of many extensions?
  • 14. Doing high speed reviews Code Reviews PHP Mess Detection Copy & Paste Detection CodeSniffer
  • 17. "Most of the time you sit next to a hairy, unfriendly colleage and argue about line indentions..." Mike http://www.flickr.com/photos/octopushat/403730001/
  • 18. And after a while you don't see code anymore! class Example {{ class Example { class Example private static $ID == 1; private static $ID = 1; private $title ==$ID private static "t3con"; 1; private $title = "t3con"; private $title "t3con"; /* /* /* // Some code II don't want to delete // Some code I don't want to delete // Some code don't want to delete public function addNothing($content) {{ public function addNothing($content) { public function addNothing($content) $content == ""; $content = ""; $content ""; return $content; return $content; }} return $content; */} */ */ public function addYear($year) {{ public function addYear($year) { public function addYear($year) return $this->title .. "" 2010"; return $this->title . " 2010"; return $this->title 2010"; }} }} } }
  • 19. Downsides of code reviews You have to search for errors You have no time Most of the time you discuss less important things No sharing of knowledge I hate my colleagues syndrome Do code reviews really ensure quality?
  • 20. Manual code reviews can cause serious damage to your nerves! You might nd your colleagues dead in front of the computer! None of our developers was harmed for this presentation! http://www.flickr.com/photos/jakub_hlavaty/2164581030/
  • 21. Wouldn‘t it be nice... If a code review could be automated? If I could see the aws before I review? Is it a dream or could it be reality?
  • 22. PHP Mess Checks your code against errors and aws.
  • 23. PHP Mess Detection Rules Code size Unused code Complexity Code length Naming Design Methods Eval Variables Inheritance
  • 24. Use PHP Mess Detector Use it on your console like this: $ phpmd . text codesize,unusedcode,naming Report format Rulesets Source path
  • 25. Example code class Example { private static $ID = 1; private $title = "t3con"; /* An unused method */ private function addNothing($content) { $content = ""; return $content; } public function addYear($year) { return $this->title . " 2010"; } public function add_year_2010($year) { return $this->title . " 2010"; } }
  • 26. Detecting the mess $ phpmd example.php text codesize,unusedcode,naming example.php:4 Avoid unused private fields such as '$ID'. example.php:4 Avoid variables with short names like $ID example.php:8 Avoid unused private methods such as 'addNothing'. example.php:13 Avoid unused parameters such as '$year'. example.php:17 Avoid unused parameters such as '$year'.
  • 27. Fixing the code class Example { private static $ID = 1; // Not used / too short private $title = "t3con"; /* An unused method */ private function addNothing($content) { // Not used $content = ""; return $content; } public function addYear($year) { // Not used return $this->title . " 2010"; } public function add_year_2010($year) { // Not used return $this->title . " 2010"; } }
  • 28. Fixing the code class Example { private $title = "t3con"; public function addYear() { return $this->title . " 2010"; } public function add_year_2010() { return $this->title . " 2010"; } }
  • 29. Copy Paste Checks your code for duplicate code.
  • 30. Duplicate code is not a little something! Unnecessary complexity Issues in architecture Hard maintainable code Multiple changes Error prone
  • 31. Back to the example code class Example { private $title = "t3con"; public function addYear() { return $this->title . " 2010"; } public function add_year_2010() { return $this->title . " 2010"; } }
  • 32. Detecting duplicate code You use it on your console like this: $ phpcpd example.php Found 1 exact clones with 2 duplicated lines in 1 files: - example.php:5-6 example.php:9-10
  • 33. Fixing the code class Example { private $title = "t3con"; public function addYear() { return $this->title . " 2010"; // Duplicate code } public function add_year_2010() { return $this->title . " 2010"; // Duplicate code } }
  • 34. Fixing the code class Example { private $title = "t3con"; public function addYear() { return $this->add_year_2010(); } public function add_year_2010() { return $this->title . " 2010"; } }
  • 36. Why coding standards? Readable code for you... ... and for others too! Maintainable by others Stop wasting time on reformating the code No more arguing about line indentions
  • 37. TYPO3 coding standards http://forge.typo3.org/projects/team- php_codesniffer Standards for: Naming Documentation Format Control structures and more...
  • 38. Install CodeSniffer The package can install like this: $ pear install PHP_CodeSniffer-alpha Then we register the TYPO3 PEAR Channel, to get the TYPO3 Coding Standard: $ pear channel-discover pear.typo3.org After that you install the TYPO3 Coding Standard like this: $ pear install typo3/PHPCS_TYPO3_SniffPool $ pear install typo3/PHPCS_TYPO3v4_Standard
  • 39. Set default Standard and use it! Set the default standard and default Tab-With: $ phpcs --config-set default_standard TYPO3v4 $ phpcs --config-set tab_width 4 Now you can use the CodeSniffer on the console for your TYPO3-Extensions: $ phpcs example.php
  • 40. One more time our example code class Example { private $title = "t3con"; public function addYear() { return $this->add_year_2010(); } public function add_year_2010() { return $this->title . " 2010"; } }
  • 41. Run CodeSniffer Use CodeSniffer on the console: $ phpcs example.php -------------------------------------------- FOUND 5 ERROR(S) AFFECTING 4 LINE(S) -------------------------------------------- 3 | ERROR | Missing class doc comment 4 | ERROR | Line indented incorrectly;… 6 | ERROR | Missing function doc comment 9 | ERROR | Missing function doc comment 9 | ERROR | Method name not camel caps
  • 42. Fixing the code // Missing comment class Example { private $title = "t3con"; // Wrong indention // Missing comment public function addYear() { return $this->add_year_2010(); } // Missing comment public function add_year_2010() { // Wrong naming return $this->title . " 2010"; } }
  • 43. Fixing the code /** * An example class. * * @author Jon Doe <john.doe@example.com> */ class Example { private $title = "t3con"; /** * Just an example function. * * @return string Some example string */ public function addYear() { return $this->addYear2010(); } …
  • 44. What developers often think: Torture and pain http://www. ickr.com/photos/mhswde/2722217304/
  • 45. What they really are: Freedom and fun http://www. ickr.com/photos/davidspinks/4453498888/
  • 46. Other usage options PHP Tool Integration - Plugin for eclipse http://www.phpsrc.org/
  • 47. Automate checking Automate tasks you do often Use CPU power to help you On a regular basis or on each commit into your version control management system Get reports instead of creating them Use a continuous integration server like Hudson or CruiseControl
  • 48. Get support from the community Register your extension at http://forge.typo3.org/start/createProject
  • 49. What is forge? Integrated social development platform for extension developers. Tools to streamline communication on projects SourceControl-Management Issue tracker Wiki NEW an integrated continuous integration server still in an early status but ready for some real world tests!
  • 50. We do quality tests for you Providing reporting and code metrics on ci.typo3.org What is currently checked? PHP Mess Detection Copy Paste Detection Making code reviews quicker and more fun!
  • 51. How do we solve the „red-light“-shock?
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59. What's next CodeSniffer phpUnit-Tests More slaves for Hudson for faster response Your ideas?
  • 61. Stop digging through code. Start with an overview. http://www. ickr.com/photos/69er/329057062/
  • 62. Reports are a good start for good quality. http://www. ickr.com/photos/ uzo/97673183/
  • 63. Tell everybody how to use the tools Most important: the youngsters! http://www. ickr.com/photos/kevenlaw/2787879806/
  • 64. Make it a movement Inspiring people to share even better with extensions of higher quality!
  • 65. dkd design kommunikation development thank you.