10. Get in touchTwitter: @__edorianXing / G+: Volker DuschStackoverflow:(visit us at http://chat.stackoverflow.com/rooms/11/phpIRC: edorianMail: php@wallbash.com 10 Introduction
11. Ask questions at any time! 11 Introduction First question gets an elePHPant Another question gets one too!
14. Even so our field is quite young 14 Motivation
15. Do you know how expensive it is to have you people around? 15 Motivation
16. 16 Motivation German numbers, ymmv €, £, Approx.. values You get around 50k a year 50.000 / Year Adding non-wage labor costs of around 60% 80.000 / Year Office space, water, hardware, coffee, plants, cleaning, drugs, travels, training 100.000 / Year 250 Days without weekends and holidays and your 30 holidays => 220 days 455 / Day When working 8 hours a day 55 Bucks per Hour! Your employer expects you to contribute over 100.000 Bucks in business value per year!
61. What to focus on?Is there anything we can base our decisions on? 38 Enough! Code! Now!
62. 39 I <2 off by one errors "There are only two hard problems in Computer Science: cache invalidation, naming things, and off-by-one errors.“ - Phil Karlton
65. The purpose of a name is to reveal intent 42 Naming matters
66. A good name tells you everything you need to know! 43 Examples! class User { public function getId() {…} public function getName() {…} /** Calculate Body-Mass-Index @link … */ public function getBMI() {…} /** @param float $kg Weight in Kilogramm */ public function setWeight($kg) {…}
67. You shouldn’t need comments 44 Code! Finally! class User { public function getUserId() {…} public function getFirst/Last/DisplayName() {…} /** @link … */ public function getBodyMassIndex() {…} /** @param float $kilogramm */ public function setWeight($kilogramm) {…}
69. Another example 46 Code! class Calendar { public function getMonth($shortened = false) {…} } class Calendar { public function getMonthNames() {…} public function getShortendMonthNames() {…} }
95. You can extend from those classes and chances are you can’t swap out ether
96.
97. Composite? 60 Another logger interface interface Logger { public function log($logMessage); public function setOutputFormat($format); public function activate(); public function deactivate(); public function flush(); public function setIncludeTimestamp($format); public function addLogger(Logger $logger); }
114. No boolean parameters 69 $user->setInactive(false); If you don’t have a very good reason! $user->setAdminStatus(false); $user->setAdminStatus(true); vs $user->revokeAdminRights(); $user->grantAdminRights();
115. Classes are nounsFunctions start with verbs! 70 $title->show(); ->createStuff(); ->deleteStuff() ->dispatchCall(); ->subscribeUser(); But never $user->admin(); or $user->bag(); $list->subscription();
116. Agree on verbs for actions 71 Don’t $dir->expunge(); Can you tell me the difference between $directory->delete($entry); And $directory->remove($entry); $router->dispatch/delegate($call); $list->add/append($user);
117.
118. Usually those functions get created for “doing the same thing with different side effects but not wanting to call it that”
119.
120. But you want long privates$user->setUserNameOrThrowAnbr />ExceptionIfNotPossible(); $logger->logMessageButDontDoAnythingbr />IfYouCantWriteToTheBackend($message); Not even: $logger->logMessage($message);
175. Recommended Reads 100 Rate my talk please! Clean Code Management Professionalism ^ Best book in 2011 ^ In my humble opinion *Book covers used under fair use More: https://www.google.com/bookmarks/l#!threadID=GU46RJYjEsMU%2FBDcqV3woQ8eH4sOcl