Don't Be Stupid, Grasp Solid - MidWestPHP

Post on 10-May-2015

4.105 views 2 download

Tags:

description

Slides from my MidWestPHP talk on 3/3/2013

Transcript of Don't Be Stupid, Grasp Solid - MidWestPHP

Don't Be STUPIDGrasp SOLID

Anthony FerraraMidWestPHP 2013

DISCLAIMERS

None Of ThesePrinciples

Are Limited To OOP

These ArePrinciples

Not Laws(Well, Some Are)

function hash_password($password = NULL, $salt = NULL, $salt2){ if($password === NULL) return FALSE;

if($salt === NULL) $salt = config_item('encryption_key');

$password = (string) $password; $salt = (string) $salt;

$ci =& get_instance();

$ci->load->library('encrypt');

$salt2 = $ci->encrypt->decode(base64_decode($salt2), config_item('encryption_key2'));

return crypt( hash_hmac('whirlpool', $password, hash('sha512', crypt($salt, '$6$rounds=100[000$' . hash('sha256', $salt) ) . '$' ) ), '$2y$12$'. $salt2 .'$' );}

STUPID

SingletonsTUPID

SingletonsTight CouplingUPID

SingletonsTight CouplingUntestable CodePID

SingletonsTight CouplingUntestable CodePremature Optimization

ID

SingletonsTight CouplingUntestable CodePremature Optimization

Indescriptive NamingD

SingletonsTight CouplingUntestable CodePremature Optimization

Indescriptive NamingDuplication

The RuleOf Three

SOLID

Single Responsibility Principle

OLID

Single Responsibility Principle

Open Closed Principle

LID

Single Responsibility Principle

Open Closed Principle

Liskov Substitution Principle

ID

Single Responsibility Principle

Open Closed Principle

Liskov Substitution Principle

Interface Segregation Principle

D

Single Responsibility Principle

Open Closed Principle

Liskov Substitution Principle

Interface Segregation Principle

Dependency Inversion Principle

Law ofLeaky

Abstractions

Law of

Demeter

Principle Of

LeastKnowledge

Principle Of

LeastAstonishment

Principle Of

GoodEnough

Anthony Ferrarajoind.in/8219@ircmaxell

blog.ircmaxell.comme@ircmaxell.comyoutube.com/ircmaxell