Created by
Jeroen De Dauw
for Wikimedia Deutschland
Licensed CC BY-SA 3.0
Collection of pointers
We want to go fast
Write code for humans
Reveal intent
usrsbscr ➜ userSubscription
Avoid disinformation
Use one word per concept
Don't try to be clever/cute
Cyclomatic complexity, NPath complexity
Minimize scope, minimize state
function onFirstPost() {
$messageText = $this->getWelcomeMessageBody();
if ($this->addFooter()) {
$messageText.= $this->getWelcomeMessageFooter();
}
$this->emailer->send($messageText);
foreach ($this->getReviewers() as $reviewer) {
$this->reviewerNotifier->notify( $reviewer );
}
}
function onFirstPost() {
$this->sendWelcomeMessage();
$this->notifyReviewers();
}
public boolean set( String attributeName, String value );
if ( set( "username", "NyanCat" ) )
public function doStuff() {
FilesystemLogger::log( 'doing stuff on Caturday is madness' );
DataStore::getInstance()->saveObject( $object );
}
function __construct( Logger $logger, DataStore $dataStore ) {
$this->logger = $logger;
$this->dataStore = $dataStore;
}
public function doStuff() {
$this->logger->log( 'doing stuff on Caturday is madness' );
$this->dataStore->saveObject( $object );
}
You Aren't Gonna Need It
Applies to features, not ease of modification
Simple design is not simple
I'm sorry I had to write you such a long letter,
but I did not have time to write you a short one
-- Blaise Pascal
Reusable solution to common problem
Communication tool
Testable code and good design go hand in hand
Trade-offs
Transcend the rules
Questions?