namespace HAL\Security;
use HAL\Security\Validator;
class DoorPasswordValidator extends Validator {
private $doorPassword = 'beneluxisawesome';
public function validate($input) {
if ($this->doorPassword !== $input) {
throw new \Exception("I'm sorry, Dave. I'm afraid
I can't do that");
}
return true;
}
}
Slide 29
Slide 29 text
We’re in!
Slide 30
Slide 30 text
Navigation
Slide 31
Slide 31 text
Read the code
Slide 32
Slide 32 text
No content
Slide 33
Slide 33 text
Don’t trust the
comments
Slide 34
Slide 34 text
namespace Casino\Game;
class Roulette {
/**
* Returns a random number
*/
private function alwaysReturnSix(){
}
}
Slide 35
Slide 35 text
namespace Casino\Game;
class Roulette {
/**
* Returns a random number
*/
private function alwaysReturnSix(){
return 4;
}
}
Slide 36
Slide 36 text
Don’t trust
the code
Slide 37
Slide 37 text
Look for
side effects
Slide 38
Slide 38 text
public function triggerFireAlarm() {
$this->startSprinklers();
$this->callFireBrigade();
$this->releaseDoorLocks();
}
Slide 39
Slide 39 text
Double Check
Your Understanding
Slide 40
Slide 40 text
Names are
important
Slide 41
Slide 41 text
Find Patterns
Slide 42
Slide 42 text
Prove you
understand it
Slide 43
Slide 43 text
I don’t
understand it
Slide 44
Slide 44 text
Debugging
Slide 45
Slide 45 text
use everything
Slide 46
Slide 46 text
Everything goes
Slide 47
Slide 47 text
DDD
Slide 48
Slide 48 text
Die Driven Debugging
Slide 49
Slide 49 text
Does this code
even run?
Slide 50
Slide 50 text
/**
* Returns a random number
*/
private function alwaysReturnSix() {
die('Yes it does');
return 4;
}
class MyVerifier extends SomethingVerifier {
public function userIsAdmin($user) {
return true;
}
}
Slide 55
Slide 55 text
XDebug
Slide 56
Slide 56 text
XDebug.scream
Slide 57
Slide 57 text
XDebug_break();
Slide 58
Slide 58 text
if (count($visitorsInLastDay) > 5){
xdebug_break();
}
Slide 59
Slide 59 text
XHPROF
Slide 60
Slide 60 text
DDD +XDebug
+ XHProf == WINNING
Slide 61
Slide 61 text
Observer Effect
Slide 62
Slide 62 text
I’m feeling better
Slide 63
Slide 63 text
But I’m still noT 100%
Slide 64
Slide 64 text
Project History
Slide 65
Slide 65 text
git log -S
Slide 66
Slide 66 text
git log -S antikythera
Slide 67
Slide 67 text
commit 5288d5804a3fc20dae4f3b2deeaa7f687595aff1
Author: Rasmus Lerdorf
Date: Tue May 24 09:33:59 2016 +0000
Add new secure storage facility. (Closes #42)
The existing storage facilities use symmetrical encryption keys which allow anyone with
the password to access them. The new storage is more secure and requires both a password and
my handprint.
There’s nothing in there yet but we’ll put the Antikythera in it as soon as it arrives
Slide 68
Slide 68 text
What’s changed
recently?
Slide 69
Slide 69 text
What changes
together?
Slide 70
Slide 70 text
Explicit
Slide 71
Slide 71 text
commit 0dc164fb052f4b838a674648aa29d83b60f01fa2
Author: Rasmus Lerdorf
Date: Fri May 20 12:14:55 2016 +0000
Added HAL to the villa’s security system on both the front and back doors
5 2 src/Villa/Structure/Door.php
14 0 test/Villa/Structure/DoorTest.php
Slide 72
Slide 72 text
Implicit
Slide 73
Slide 73 text
commit 2915dabebc8b87b84ec40fac0f4954fb84f3b7cd
Author: Rasmus Lerdorf
Date: Sun May 22 21:27:31 2016 +0000
Bought a new car. Updated town parking permit to new registration
12 0 src/Garage/Car/Ferrari.php
1 1 src/Town/ParkingPermits/Rasmus.php
//
// Dear maintainer:
//
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
//
// total_hours_wasted_here = 42
//
I’ve been @mheap, you’ve been awesome!
https://joind.in/talk/b0184