Skip to content

Instantly share code, notes, and snippets.

View meza's full-sized avatar
👋
tweet me if I missed a PR

Meza meza

👋
tweet me if I missed a PR
  • London, United Kingdom
  • 13:48 (UTC +01:00)
View GitHub Profile
@meza
meza / TimeValidator.php
Created October 24, 2011 09:10
TDD vs. Regular Expressions - coding kata
<?php
class TimeValidator
{
public function isValid($time_specification)
{
return 1 == preg_match($this->buildRegExp(), $time_specification);
}
private function buildRegExp()
@meza
meza / globalState.java
Created May 7, 2012 13:16
global state antipattern
class Book {
private String title;
private String author;
private int price;
public String getTitle() {
return title;
}
@meza
meza / globalState2.java
Created May 7, 2012 13:19
Simplified global state
class Book {
public String title;
public String author;
public int price;
}
@meza
meza / globalState3.java
Created May 7, 2012 13:27
Book consumer
class BookConsumer {
public void printTheTitleOfABook(Book book) {
if(!book.getTitle().isEmpty()) {
System.out.println(book.getTitle());
}
}
}
class Book {
private String title;
private String author;
private int price;
public Book(String title, String author, int price) {
this.title = title;
this.author = author;
this.price = price;
@meza
meza / GreetPrinter.java
Created June 22, 2012 13:53
User class
public class GreetPrinter {
public void static main(String[] args) {
User user = new User();
if (args.length > 1) {
user.setEmail(args[0]);
}
Greeter greeter = new Greeter();
String msg = greeter.greetMessage(user);
if (msg != null) {
System.out.println(msg);
public class GreetPrinter {
public void static main(String[] args) {
if (args.length < 1) {
throw new RuntimeException("No email");
}
User user = new User(args[0]);
Greeter greeter = new Greeter();
System.out.println(greeter.greetMessage(user));
}
@meza
meza / DemoCalss.php
Created October 13, 2012 12:09
Blog - Refactoring 1 - step1
<?php
class DemoClass
{
public function someMethod()
{
$val1 = SomeClass1::staticMethod1();
$val2 = SomeClass2::staticMethod2();
}
public function process()
public class SuperfluousAccessors {
public boolean anUnderstandablyLongVariableNameForAnOddUsecase;
}
@meza
meza / .gitignore
Created November 19, 2012 18:30
Feature file lock
*.*
!README
!*.feature
!*.gitignore