Extended slide deck of my September 2011 Flash on the Beach presentation "Robotlegs 2 and your brain - a great developer toolchain".
The presentation asks the question - what do programmers need to know about how their brains work? And how did we employ cognitive and neuroscience to make decisions about version 2 of the Robotlegs ActionScript framework.
If you're brand new to Robotlegs then the coverage of the workings of Robotlegs 1 are likely to be insufficient - I'd suggest picking up a copy of ActionScript Developers Guide to Robotlegs first.
More details are available at www.robotlegs.org
3. Team Robotlegs Joel Hooks
Ro botlegs
Core
Robot legs or iginator Signals
Shaun Smith
Robert Penner
Till Schneidereit
Swiftsuspenders
and me, Stray (behind camera)
3
11. What do we mean
by “framework”?
A framework is a tool
11
12. What do we mean
by “framework”? Take 30 seconds to
A framework is a tool list as many things as
you can think of that
you could do with
this tool.
12
13. What do we mean
by “framework”?
A framework is a tool
Most people would say that this is
a better screwdriver, but how
many things on your list can’t be
done with this tool?
13
14. I used the correct
size of screwdriver
for this screw.
Using the wrong tool can be I used the wrong
frustrating, or - worse - it can size of screwdriver
result in the work becoming for this screw.
‘broken’ beyond repair.
14
34. Multi-tasking FTL!
Our lizard brain is fine at multi-
tasking, but our problem-solving
brain isn’t. When we try to multi-
task our performance in even
simple tasks dramatically reduces.
35. Architecture & Coding
are different tasks
Using Robotlegs should
allow you to focus more
cleanly on one or the other.
When you’re coding a class,
thoughts about architecture
shouldn’t be intruding.
36. Working memory
• The ‘RAM’ we use to hold things in mind in
order to solve a problem.
• Items stored in working memory are
regularly garbage collected - you won’t
remember them later.
• Programmers rely heavily on working
memory when carrying concepts within and
between classes.
37. Working memory test
Give yourself 30 seconds to
commit the following list of
words to memory, and then
move to the next slide.
38. Working memory test
refugee mill architect
quilt mermaid pimple
weather salary wallet
laundry tram verse
internet athletics thunder
eyebrow nurse space
chess seal egg
flight stamp system
39. Working memory test
Now write down as many as
you can remember. Order is
not important. Give yourself
30 - 60 seconds.
40. Working memory test
Check your answers.
refugee mill architect
quilt mermaid pimple
weather salary wallet
laundry tram verse
internet athletics thunder
eyebrow nurse space
chess seal egg
flight stamp system
41. Working memory test
Most people remember 6 - 9
words.
I’m now going to challenge you to
remember more than twice as
many, from a different list of 25.
Again, give yourself 30 seconds to
memorise them, and then move
to the next slide.
42. Working memory test
25 words - 30 seconds
War and peace Nobody does it better
Over the rainbow Love and war
Cats and dogs I’ll be back
Night before Christmas ctrl, alt, delete
43. Working memory test
25 words - 30 seconds
Now write down as many as
you can remember. Order is
not important. Give yourself
30 - 60 seconds.
44. Working memory test
25 words - 30 seconds
Check your answers - count
every word that you got correct.
War and peace Nobody does it better
Over the rainbow Love and war
Cats and dogs I’ll be back
Night before Christmas ctrl, alt, delete
45. Chunking FTW!
Your working me
7±2 of 7 ‘plus or min
mory consists
us 2’ chunks
46. Chunking is like ‘zip’ for your working memory
up and Mickey
down Mouse
nurse 747
7 7,8,9
A chunk can be a single A chunk can be a
word or number sequence, set or pattern
that you have met before
47. Chunking uses neural networks
Peace
Pipes
War Repeated simultaneous firing
of individual neurons creates
connections between them.
Triangle
Euclid
Love
49. If you wrote crap code today,
you hard wired your brain to
...
49
50. If you wrote crap code today,
you hard wired your brain to
find it easier to write crap
code tomorrow.
50
51. Chunking and Robotlegs
We want Robotlegs to occupy as few chunks as
possible, leaving most of your working memory
free to tackle your specific problem.
52. Are you bored yet?
If you are, this presentation isn’t causing
you to create enough dopamine. 52
53. Dopamine
Dopamine is a neurotransmitter. Like engine oil for
your brain. It helps you to stay on task and also
makes you more effective at problem solving.
53
55. Dopamine
Vicious Circle - not enough
dopamine => distracted,
unproductive, prone to
mistakes, slow progress => Virtuous Circle - plenty
lower dopamine. dopamine => focussed,
productive, insightful, fast
progress => more dopamine.
Distracted Focussed
55
56. Dopamine is key to
pattern recognition
Helps you find ‘the zone’ and stay there
56
57. You noticed that some of these
shapes were different, without
deciding to look for differences.
We call this ‘pre-attentive’ processing.
Helps you find ‘the zone’ and stay there
57
58. Give yourself 6 seconds to
estimate the number of
triangles in the next picture
58
67. Cognitive dissonance can
be meaningful and directing
Fighter pilots rely on it for rapidly detecting problems.
It can also tell you that something is wrong with your code.
67
68. Cognitive dissonance can be
meaningless and distracting
Event.ADDED
Event.COMPLETE
To me, it feels like there’s something
wrong when I mix cases in event types.
68
70. Meaningful, directing
In order to tune in to
this, we need to limit the
amount of cognitive
vs dissonance the Robotlegs
framework triggers.
Meaningless, distracting
70
74. Great solution,
wrong problem.
It’s a really lovely yoda suit for a
dog, but who needs one of those?
75. ‘Right execution of the wrong thing’
happens when one half of our brain
dominates decision making.
Left brain Right brain
(right hand) (left hand)
75
76. A brain of two halves
Left brain Right brain
(right hand) (left hand)
• Specific • Context
• Details • Big picture
• Calculation • Estimation
76
77. Programming is whole-brain
problem solving
Left brain Right brain
(right hand) (left hand)
“How to do it right” “The right thing to do”
Emerges as specific Emerges as somatic
thoughts (body) feelings
77
80. Brain Summary
• Avoid multi-tasking
• Take advantage of chunking
• Dopamine is key to staying in flow
• Make cognitive dissonance meaningful
• Programming is a ‘whole brain’ activity
• Metaphor activates the ‘whole brain’
80
83. What is Robotlegs?
“ActionScript 3
communication,
cooperation,
and configuration
framework”
[robotlegs]
83
84. Writing code is easy
Very clever class
that gets and A menu
A really
sends data to accepting user
tasty view
and from a input
server
A clever class that
checks whether Another really
A quite simple tasty view
class that does input is valid
stuff with XML
84
85. Joining code together is hard
Very clever class
that gets and A menu
A really
sends data to accepting user
tasty view
and from a input
server
A clever class that
checks whether Another really
A quite simple tasty view
class that does input is valid
stuff with XML
85
86. A “dependency” is just a need to
use an instance of another object
for communication,
cooperation,
or configuration
86
87. “Dependency Injection”
var kittenPath:String = “http://kittens978.com/feed.xml”;
var kittenRequest:URLRequest = new URLRequest(kittenPath);
_kittenLoader = new URLLoader(kittenRequest);
87
88. “Dependency Injection”
var kittenPath:String = “http://kittens978.com/feed.xml”;
var kittenRequest:URLRequest = new URLRequest(kittenPath);
_kittenLoader = new URLLoader(kittenRequest);
88
89. DI can lead to a lot of
“pass the parcel code”
Animation
timing
View class that has nothing to do with
timing, or feeds, but creates and contains
the animation and the menu
Feed
details
Animation class Menu class that
that times the displays feeds to
fading of images the user
89
90. Static Singletons
One approach to solving
the ‘pass the parcel’
dependency chain problem.
90
91. Static Singletons
Suck
• ImposeSingleton class
on the
extra responsibilities
• Impose extra knowledge on
the using class
• Very difficult to vary and test
corner cases
91
93. The Robotlegs dream:
Dependency Inception
A an object inside
an object inside
an object inside
an object... and
Feed
details nobody knows
how it got there
- it just
appeared.
93
94. To declare a dependency
[Inject]
public var importantCollaborator:ICollaboratorClass;
94
95. Injections recipe
Class with Injected
[Inject] object
requirements
The
Robotlegs
Injector is
just a factory
95
96. Injection opens up possibilities
• Communication via a shared eventDispatcher instance
• “Mediators” - connecting (dumb) views to your application
• The Command Pattern
96
99. Commands are snack-size
controllers, triggered by events
Feed Loader
Service
FeedSelectorEvent.
Mediator FEED_SELECTED Command with
[Inject] requirements
99
100. Again: Injection is not magic
• The Injector is just a factory
• It needswithbe pre-advised about how
to deal
to
injection requests
100
101. How to tell the injector
what to do
injector.mapSingletonOf(IFeedService, XMLFeedService);
injector.mapValue(IFeedConfig, new DefaultFeedConfig());
101
102. Robotlegs 1 - Feature recap
• [Inject] dependencies
• Shared eventDispatcher
• Mediators automatically created & destroyed for views
• Commands mapped to events
102
105. Robotlegs uses ‘Semantic
versioning’
• Point releases must be backward compatible - eg 1.3 can be dropped
in to an application previously using 1.2, without breakages.
• Major releases (eg 2.0 vs 1.0) can rewrite the API.
• This gives us great freedom in terms of Robotlegs 2.0
• but...
105
115. In unfamiliar territory, we can
lose our ‘right brain’ context.
We feel lost.
New and upgrading users want
a quick push in the right
direction.
115
116. 4 new Robotlegs 2 ‘flavours’
Performance
Fast Flexible
Clean
116
117. Choose one to start your project
Performance
Fast Flexible
Clean
117
134. Less cognitive dissonance,
more flow
We often create big
classes with multiple
responsibilities in order
to create a sense of flow.
134
135. Less cognitive dissonance,
more flow
Robotlegs can help you stay
in flow even when working
with larger numbers of
smaller classes.
And speaking of separating
responsibilities...
135
137. “Soft” mappings
Excuse me, if
Injections recipe
nobody else has already
created a mapping for this,
then I’ll oblige.
Allows you to use this
module stand-alone or in
combination with other
Robotlegs modules.
Without recompiling!
137
142. Robotlegs 2: Feature overview
• Build your context - have it your way • Rule sets
• Fluency / mxml • Multiple mediators
• 4 Robotlegs ‘flavours’ • Type matchers
• Command flows • The InspectorGadget
• Mix view management strategies • Modular just works
142
143. Release process
• Alpha releases: API still in flux
• Beta releases: API locked, future proof
• One feature at a time
• Match v1 Feature set
• As fast as we can!
143