- You are not as smart
as you think you are,
but don't take it personally.
What I'm really talkin' about is we,
as humans, are not as
smart as we think we are.
So I'm including myself in that,
even though I'm the one
up here telling you this,
so, how does that work?
Well, it's a bit like Hofstadter's Law.
You remember Hofstadter who wrote
Godel, Escher, Bach, The
Eternal Golden Braid?
So, he coined Hofstadter's Law,
it always takes longer than you expect,
even when you take into
account Hofstadter's Law.
(audience laughs)
So, similarly, I coined Phil's Law,
you're not as smart as you think you are,
even when you take into
account Phil's Law.
(audience laughs)
It's the same thing, so, yeah,
I include myself in that.
Well, what am I really
talking about when I say,
you're not as smart as you think you are?
Well, it's all about cognitive limits.
And to give you an idea what
I mean, I wanna burn most
of the rest of my first three minutes
with a video and, 'cause
I'm burning that time,
please pay close attention,
even if you've seen this before.
- [Narrator] Count how many
times the players wearing white
pass the ball.
(audience laughing)
Sh.
The correct answer is 16 passes.
Did you spot the gorilla?
(audience laughing)
- [Audience Member] Yeah!
- [Narrator] For people
who haven't seen or heard
about a video like this before,
about half miss the gorilla.
If you knew about the
gorilla, you probably saw it.
But did you notice the
curtain changing color
- [Phil] Ah!
or the player on the black
team leaving the game?
(audience laughing)
Let's rewind and watch it again.
(rewinding tape screeching)
Here comes the gorilla
and there goes a player
and the curtain is
changing from red to gold.
(audience laughing)
When you're looking for a gorilla,
you often miss other unexpected events.
(audience laughing)
(audience clapping)
And that's the monkey business illusion.
Learn more about this illusion
- Have to play this bit,
- and the original
gorilla experiment
- won't be a moment.
at theinvisiblegorilla.com.
- So, it's hard for us
to keep track of things
but really, I mean, how bad is it?
And how does this relate to our code
'cause that's really what
we're here to talk about.
(audience laughing)
So, let's talk about magic numbers.
Specifically, the magic number
seven, plus or minus two.
(audience laughing)
so you've probably heard this
before, this was made popular
by a George Miller, cognitive
psychologist in the '60s.
He discovered there was a
limit in our working memory
of about seven items, plus or minus two,
that we can hold in our heads at once.
And in fact he later revised
that figure down to about five.
And the important thing is
we're all about the same,
with only a very small variance.
So, none of us are particularly
smarter than anyone else
in this respect.
And, what's interesting,
is this limit comes up
in lots of different ways.
For example, there's a
phenomenon known as subitizing.
Who here has heard of subitizing?
One hand.
Well, everyone is I'm sure
familiar with the concept.
So, you can see four items here
and you didn't have to count them.
You could just look at
this and see the fourness.
And it's not because they're
arranged in a pattern.
If I do this, well,
it's still easy to see,
there's four items, we
don't have to count them,
you can see it straight away.
What if I do this?
Ever so slightly harder now.
Now, maybe you counted them or
maybe you just saw two groups
of three or three groups of two.
Point is, that you can't
really take in six,
for most people.
But, if I do this, now
we see six straight away
because we recognize a pattern.
And this is how we deal with complexity.
By abstracting into patterns.
It's called chunking
in psychological terms.
So, starting to get an idea
of how this might relate
to our code.
Mention abstraction.
So, I mentioned earlier Hofstadter's Law.
(audience laughing)
He wrote the book An Eternal Golden Braid.
Did you know the Latin
word for braid is plex.
Which is interesting
because that's the root
of the word complex which means
many folds or many braids.
We get our modern word complex from that.
Similarly, a simplex is something
with just one fold or braid.
We can see how they relate.
And of course we get our
modern word simple from that.
Notice that it makes really
clear in the illustration.
We're not talkin' about many things,
it's not the number of
things that's important,
it's their interaction,
it's how they cross over.
The folds or the braids.
Similarly with our code,
it's not the number of things
in our code that makes it complex.
It's how they interact.
So whether that's through threading,
or whether it's immutability,
which actually complex time and value,
or global variable with singletons.
Anything that conflates
different part of the code
so that by looking at one
piece of code you have to think
about another piece of code,
just to be able to reason about it.
All these things are the things
that make it complex in a way
that is hard for us to hold
in our heads at one time.
So knowing that that limit is
really small for all of us,
we need to minimize those things,
minimize that sort of complexity.
So, been a few talks on
touching on simplicity
at this conference already.
So if you didn't catch any of these,
do watch them on YouTube.
I've done a talk on
simplicity myself before,
so you can find that on my website.
And I'm gonna be doing a
class this weekend on TDD
but, actually this material's been taken
from that class because,
big thing about TDD is
that it forces our designs
to be simpler.
And that's a big part of
how TDD actually works
and how we get value from
it in simplifying our code.
So, you're not as smart
as you think you are.
(audience laughing)
But it's okay, we can handle it.
Thank you very much.
(audience applauding)
