+ All Categories
Home > Software > Object invariants, immutability & you full talk (v1) - AmsterdamPHP

Object invariants, immutability & you full talk (v1) - AmsterdamPHP

Date post: 17-Jul-2015
Category:
Upload: jeroen-vd-gulik
View: 193 times
Download: 1 times
Share this document with a friend
Popular Tags:
67
Object Invariants, Immutability & You Making Objects Do Your Bidding AmsterdamPHP 15-01-2015
Transcript

Object Invariants, Immutability & You

Making Objects Do Your Bidding AmsterdamPHP 15-01-2015

Jeroen v.d. Gulik

• CTO / Co-Founder Isset (http://isset.nl)

• Builder of Artificial Stupidity

• @n0x13

• Likes Cats … a lot

Isset Internet Professionals• We build custom internet technology based solutions

• We helped design and build several online video platforms (Pathé Thuis, Videoland, NPO Plus)

• Currently focussing on video-transcoder.com

• We like a challenge so if you have interesting problems to solve, come and talk to me

• Still Hiring

“Every Great Talk should start with a Great Quote”

- Ross Tuck-

-House M.D.

Telephone Game

“Over time, the original intent and purpose

gets lost”- Jeroen v.d. Gulik

“A Customer should always have an email

address”

Testing shows the presence, not the absence

of bugs. - Joseph Stalin

“We should enforce (business) rules when

creating objects” - Mao Zedong

“A Customer should have a valid email address”

Outside-in validation should be avoided

- Albert Einstein

Objects should be responsible for their own

internal consistency - Barack Obama

● Single Responsibility Principle

● Duplicate code

Design by contract

Value Object

● Small Objects

● Equality based on value

● Immutable

Entity Object

● Usually big(-ger)

● Equality based on Identity

● Mutable

● Can change over time

Immutability● Simplifies code

● Less cognitive load

● Guaranteed consistent

● Referencing without breakage

● Easy to test

● Caching (profit!)

Immutable Object, Best Object

- The Hulk

“A Customer should have a valid email address and a

password”

Make the Implicit, Explicit

Objects as dumb data stores

This is our industry standard

Published ?

Objects should have behaviour attached

to them- Julius Caesar

Objects should tell a tale about its current state and all the possible

ways to change that state- Bruce Lee

Schrödinger's cat

UnpaidOrder PaidOrder

“Sounds like a State Machine”- Igor Wiedler

Immutability

UnpublishedArticle PublishedArticle

UnpublishedArticle PublishedArticleDraft Article

Draft Article RetractedArticle

Objects should only expose methods relevant to it's

current state - George Bush

Objects should …

• Be responsible for their own internal state

• Have specific behaviour towards its responsibility

• Broadcast their state

• Only care about the state it’s currently in.

Magic is bad, hmmmkay- Saddam Hussein

Questions?Please rate my talk: https://joind.in/event/view/

3267


Recommended