How to improve the quality of your TYPO3 extensions
-
Upload
christian-trabold -
Category
Technology
-
view
5.552 -
download
5
description
Transcript of How to improve the quality of your TYPO3 extensions
![Page 1: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/1.jpg)
How to improve the quality of your TYPO3 extensionsChristian TraboldMike Zaschka
2nd October 2010, TYPO3 Conference Frankfurt
![Page 2: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/2.jpg)
Agenda
What‘s the problem?
High speed code reviews
Tools that help you
Questions & Answers
![Page 3: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/3.jpg)
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
![Page 4: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/4.jpg)
Who are we?
http://www.flickr.com/photos/kevenlaw/2684465429/
![Page 5: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/5.jpg)
About us
Christian Trabold
Senior Developer
Web since 1999TYPO3 since 2004dkd since 2006
Focus on quality assurance
Author of TYPO3 Kochbuch, O‘Reilly
E-Mail [email protected] @ctrabold
![Page 6: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/6.jpg)
About us
Mike Zaschka
Senior Developer
TYPO3 since 2005Ruby/Rails since 2007dkd since 2008
eMail [email protected] Twitter @mike_zaschka
![Page 7: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/7.jpg)
What is our problem?
![Page 8: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/8.jpg)
We all want a perfect extension
TYPO3 API
Security cookbookTYPO3 coding standards
![Page 9: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/9.jpg)
BUTWe all want a perfect extension
![Page 10: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/10.jpg)
High complexity
Nobody wants to touch it.
![Page 11: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/11.jpg)
No documentation
Nobody understands it.
![Page 12: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/12.jpg)
Different standard
Nobody can read it.
![Page 13: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/13.jpg)
How do you monitor the quality of many extensions?
![Page 14: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/14.jpg)
Code ReviewsPHP Mess DetectionCopy & Paste Detection CodeSniffer
Doing high speed reviews
![Page 15: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/15.jpg)
Code Reviews
Quality assurance with talking.
![Page 16: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/16.jpg)
CODE REVIEWS
SUCK
![Page 17: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/17.jpg)
http://www.flickr.com/photos/octopushat/403730001/
"Most of the time you sit next to a hairy, unfriendly colleage and argue about
line indentions..."Mike
![Page 18: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/18.jpg)
And after a while you don't see code anymore!
class Example { private static $ID = 1; private $title = "t3con"; /* // Some code I don't want to delete public function addNothing($content) { $content = ""; return $content; } */ public function addYear($year) { return $this->title . " 2010"; }}
class Example { private static $ID = 1; private $title = "t3con"; /* // Some code I don't want to delete public function addNothing($content) { $content = ""; return $content; } */ public function addYear($year) { return $this->title . " 2010"; }}
class Example { private static $ID = 1; private $title = "t3con"; /* // Some code I don't want to delete public function addNothing($content) { $content = ""; return $content; } */ public function addYear($year) { return $this->title . " 2010"; }}
![Page 19: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/19.jpg)
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?
![Page 20: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/20.jpg)
http://www.flickr.com/photos/jakub_hlavaty/2164581030/
You might !nd your colleaguesdead in front of the computer!
Manual code reviews can cause serious damage to your nerves!
None of our developers was harmed for this presentation!
![Page 21: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/21.jpg)
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?
![Page 22: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/22.jpg)
PHP Mess
Checks your code against errors and !aws.
![Page 23: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/23.jpg)
PHP Mess Detection Rules
Code size
ComplexityCode length
Design
EvalInheritance
Naming
MethodsVariables
Unused code
![Page 24: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/24.jpg)
Use PHP Mess Detector
Use it on your console like this:
$ phpmd . text codesize,unusedcode,naming
Rulesets
Report format
Source path
![Page 25: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/25.jpg)
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"; } }
![Page 26: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/26.jpg)
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 $IDexample.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'.
![Page 27: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/27.jpg)
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"; } }
![Page 28: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/28.jpg)
Fixing the code
class Example { private $title = "t3con"; public function addYear() { return $this->title . " 2010"; } public function add_year_2010() { return $this->title . " 2010"; } }
![Page 29: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/29.jpg)
Copy Paste
Checks your code for duplicate code.
![Page 30: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/30.jpg)
Duplicate code is not a little something!
Unnecessary complexity
Issues in architecture
Hard maintainable code
Multiple changes
Error prone
![Page 31: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/31.jpg)
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"; } }
![Page 32: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/32.jpg)
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
![Page 33: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/33.jpg)
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 }}
![Page 34: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/34.jpg)
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"; } }
![Page 35: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/35.jpg)
CodeSniffer
Checks your code against a coding standard.
![Page 36: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/36.jpg)
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
![Page 37: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/37.jpg)
TYPO3 coding standards
http://forge.typo3.org/projects/team-php_codesniffer
Standards for:
Naming
Documentation
Format
Control structures
and more...
![Page 38: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/38.jpg)
Install CodeSniffer
The package can install like this:
$ pear install PHP_CodeSniffer-alpha
Then we register the TYPO3 PEAR Channel, to getthe TYPO3 Coding Standard:
$ pear channel-discover pear.typo3.org
After that you install the TYPO3 Coding Standardlike this:
$ pear install typo3/PHPCS_TYPO3_SniffPool$ pear install typo3/PHPCS_TYPO3v4_Standard
![Page 39: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/39.jpg)
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
![Page 40: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/40.jpg)
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"; } }
![Page 41: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/41.jpg)
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
![Page 42: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/42.jpg)
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"; }}
![Page 43: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/43.jpg)
Fixing the code
/** * An example class. * * @author Jon Doe <[email protected]> */class Example { private $title = "t3con";
/** * Just an example function. * * @return string Some example string */ public function addYear() { return $this->addYear2010(); } …
![Page 44: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/44.jpg)
What developers often think:
Torture and pain
http://www."ickr.com/photos/mhswde/2722217304/
![Page 45: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/45.jpg)
http://www."ickr.com/photos/davidspinks/4453498888/
Freedom and fun
What they really are:
![Page 46: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/46.jpg)
Other usage options
PHP Tool Integration - Plugin for eclipse
http://www.phpsrc.org/
![Page 47: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/47.jpg)
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
![Page 48: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/48.jpg)
Get support from the community
Register your extension athttp://forge.typo3.org/start/createProject
![Page 49: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/49.jpg)
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!
![Page 50: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/50.jpg)
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!
![Page 51: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/51.jpg)
How do we solve the „red-light“-shock?
![Page 52: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/52.jpg)
![Page 53: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/53.jpg)
![Page 54: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/54.jpg)
![Page 55: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/55.jpg)
![Page 56: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/56.jpg)
![Page 57: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/57.jpg)
![Page 58: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/58.jpg)
![Page 59: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/59.jpg)
What's next
CodeSniffer
phpUnit-Tests
More slaves for Hudson for faster response
Your ideas?
![Page 60: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/60.jpg)
Conclusion
![Page 61: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/61.jpg)
Start with an overview.
Stop digging through code.
http://www."ickr.com/photos/69er/329057062/
![Page 62: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/62.jpg)
http://www."ickr.com/photos/"uzo/97673183/
Reports are a good start for good quality.
![Page 63: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/63.jpg)
http://www."ickr.com/photos/kevenlaw/2787879806/
Most important: the youngsters!
Tell everybody how to use the tools
![Page 64: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/64.jpg)
Inspiring people to share
Make it a movement
even better with extensions of higher quality!
![Page 65: How to improve the quality of your TYPO3 extensions](https://reader031.fdocuments.in/reader031/viewer/2022012312/558cdea0d8b42a015a8b4615/html5/thumbnails/65.jpg)
d dkdesignkommunikationdevelopment
thank you.