Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to...

51
Když něco rozeberem, tak leda debuggerem WebExpo 2009 – Praha Mgr. Juraj Michálek SinusGear Twitter: http://twitter.com/georgiksk Blog: http://georgik.sinusgear.com

Transcript of Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to...

Page 1: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Když něco rozeberem, tak leda debuggerem

WebExpo 2009 – Praha

Mgr. Juraj MichálekSinusGear

Twitter: http://twitter.com/georgikskBlog: http://georgik.sinusgear.com

Page 2: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Tak čo rozoberieme?

Bug

Ladenie

Debuggovanie(lokálne aj vzdialené)

Bez debuggeru a predsa bezpečne

Zaujímavosti

Page 3: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Bug

Page 4: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Čím trávi vývojár najviac času?

Ladením.

Debuggovaním.

Facebookom ;-)

Page 5: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Ladíme

Prvý prístup:

Logujeme.

Page 6: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Debugger

Krok a stop.Krok a stop.Krok a stop.

Page 7: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Uvedené príklady z Eclipse

Page 8: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Break point

Page 9: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Naštartujeme Debugger

Page 10: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

A zastavíme

Page 11: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Prechádzka po stacku

Page 12: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Výhody dobrého debuggera

Zastavenie v mieste break-pointu.

Vizualizácia hodnôt.

Stack trace.

Page 13: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Ladíme lokálnu aplikáciu

Možnosti:

Aplikácia vrámci workspacu.(videli sme)

Aplikácia mimo workspace.(ukážeme si)

Page 14: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Import binárky

Page 15: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Toto ešte zvládneme

Page 16: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

A teraz príde trik – bez medzier!

Nesprávne!

Správne

Page 17: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Drobnosti pred štartom

Page 18: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Debug – lokálna aplikácia

Page 19: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Čo z bežiacimi aplikáciami?

Pripojíme sa na aplikáciu.

Page 20: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Pripojenie k bežiacenu procesu

Page 21: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Čo s aplikáciami na serveri?

Väčšina debuggerov podporujevzdialené pripojenie.

Page 22: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Aplikácia to neprežila

Post-mortem analýza

Zostal len jej obraz: coredump

Page 23: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Ukladanie pádov Apache

Do konfigurácie pridať:

CoreDumpDirectory /tmp/

Page 24: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Rýchla analýza coredumpu

Page 25: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Módy debuggera

Spustenie lokálnej aplikácie.

Pripojenie k lokálnemu procesu.

Pripojenie k vzdialenému procesu.

Post-mortem.

Page 26: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Debugujeme PHP

Page 27: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Eclipse + PHP Development Tools

Pozor!Neobsahuje Zend Debugger

Dá sa získať z:http://www.zend.com/community/pdt

Page 28: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

PHP Zend Debugger

Page 29: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Debug as PHP script

Page 30: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Skúsme čo na to Apache

Nezastavil!

Page 31: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Drobná úprava v php.ini

zend_extension=/home/g.../ZendDebugger.sozend_debugger.allow_hosts=127.0.0.1

zend_debugger.expose_remotely=alwayszend_debugger.connector_port = 10013

Page 32: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Pohoda s PHP

Page 33: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Debugger - zhrnutie

Debuggovať ide všetko!

Len konfigurácia nástrojov nemusí byťokamžite zrejmá.

Page 34: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Čím trávi vývojár najviac času?

Ladením.

Debuggovaním.

Facebookom ;-)

Page 35: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Zmena paradigmy

Zkuste to bez debuggeru!

Milý Marconi!

- Jára Cimrman,průkopník v hodu HDD do dálky

Page 36: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Odstránenie debuggovania

Riešenie je jednoduché!

Kód bez chýb!

Page 37: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Unit testy

Kód rozdelíme.

Napíšene automatizované testy.

Page 38: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Mňáá to zdržuje!

„Písanie testov zdržuje od reálneho kódu.“

„Musím rýchlo písať kód, šéf chce po mne funkcie“

„Testy som vypol, lebo neustále padali.“

Page 39: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

OMG !

Page 40: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Vývojár si neuvedomuje, že

nepísaním testov:

Predražuje svoju prácu.

Oneskoruje dodávku produktu.

Poškodzuje ostatných vo firme.

Znižuje možnosť ďalšieho rozšírenia produktu.

Neposkytuje dokumentáciu k svojmu kódu.

Page 41: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

PHPUnit - je to tak jednoduché!

Easy to learn to write.Easy to write.Easy to read.

Easy to execute.Quick to execute.

Isolated.Composable.

Page 42: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Príklad z PHPUnit

Page 43: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Spustenie testu

Page 44: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Statická analýza kódu

Security hole

Page 45: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

RATS

http://www.fortify.com/security-resources/rats.jsp

Page 46: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Švajčiarský nožík - NetCat

test.txt:GET /index.html HTTP/1.1Host: localhostConnection: close prázdny riadok

nc localhost 80 <test.txtnc localhost 80 <test.txt

Page 47: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Pár zaujímavostí

Page 48: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Software Engineering Radio

http://www.se-radio.net

Page 49: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Adrenaline Junkies and Template Zombies

Vzory správaniav projektoch

Page 50: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Priestor na otázky.

WebExpo 2009 – Praha

Mgr. Juraj MichálekSinusGear

Twitter: http://twitter.com/georgikskBlog: http://georgik.sinusgear.com

Page 51: Když něco rozeberem, tak leda debuggerem · PHPUnit - je to tak jednoduché! Easy to learn to write. Easy to write. Easy to read. Easy to execute. Quick to execute. Isolated. Composable.

Ďakujem za pozornosť!

WebExpo 2009 – Praha

Mgr. Juraj MichálekSinusGear

Twitter: http://twitter.com/georgikskBlog: http://georgik.sinusgear.com