Friday, September 30, 2016

Textmate Regular Expressions

To remove numbers in the format 12:34, enter the regular expression:

 ^\d{2}:\d{2}$

in the find field, click on regular expression and click Replace All. To replace two new lines with one new line:

Find: [\n]+
Replace : \n

Thursday, September 29, 2016

Ruby Conference 2007 Advanced Ruby Class Design by Jim Weirich

I work for edge case which is a Rails development company have been working on
for about six months before the app
I was are pretty involved in the Java world as well doing Ruby
are and Java kinda at the same time so that's kinda my back row talk a little
bit about that but first I wanna
mention the word advanced here you might work think what he's really
going to go deep into some really complicated
are Ruby code here and that's really not the case what I want to talk about is
not so much the advanced Park
with the roomie part about iPhone
that arm language
particularly programming languages him to shove
shaping for the way you think so let me give you a little bit of my background
so you understand where I am coming from I the very first programming language
ever learn
was four crayon and that was in my physics class and work but not for
cramped drive some Calcot waters
also to plot the data from our physics lab experiments
that was great a really loved it it turned out of
I've kind of all the whole computer science thing rather than the physics
things after I got outta college
our first few jobs involve courtroom from their idea doesn't see programming
got very involved in model 2 does anybody remember Mar 02
at the time
it was up I was there beautiful language
it have a really great concept in the things I was worried about when I'm
was bottler 30 cohesion and coupling am also too I felt got a lot of those
things
exactly right from that point then I started getting involved in
object-oriented languages
which took the ideas of coupling and cohesion and modularity
even farther so C pas pas was my first entry and object-oriented design
up from there I got in the eiffel eiffel party but contractor
out to right reliable software rate lined with beautiful
in its own way beautiful in a very different way the ruby is
still a beautiful language in its own right I think a also
involved in the Java law alongside about the second programming language ever
learned was worth
yes these are your father's parentheses
and is quite by accident see I signed up
when I discovered hey this programming thing is kinda fun in my junior year in
college I signed up for
introduction before current programming so I could learn four credits will but
better
I got a class and the instructor
started drawing core code on the blackboard we didn't even have white
works backgrounds
those are all it is OK star writing code on the black poor
I know something right away it had way too many purposes to be four per
i sat in that class for three days
totally confused I had no idea what he was doing
why all those processes are you a little better for Priya
I knew this wasn't right over certain it dawned on me
what he was doing with the print the season because the recursion
the whole thing it turns out this
introduction introduction to 4 per course had Daniel Friedman
as the instructor Daniel Friedman those are you know north
the author of the littlest for the little schemer all that you've just come
out with a little less per book
at that time so we were getting a lot of good little whisper
are techniques thrown at us
in class and we learned with sparboe first reporters that the courts and then
we switched over 24 cramped so we did get our introduction
before print eventually but by then I was hooked so I learned left
after our college arm I got the ball before 4th was great because it's a
its interactive language but its
design first systems will release more resources and I didn't have a lot of
money just got a college
I don't have enough money to buy the ER it was either in Apple to
we or Apple to RR trs-80 those with the big computers back
I'm I don't even have enough money for them right out of college so I bought a
little
single board computer with UK if memory of
you know what fourth runs great to cave memory I had a
editor an assembler compiler and enough for my application code all in 2k a
memory which is really cool
fourth was very attractive not dynamically typed in any way you like
ruby is but it was interactive in the same way that Ruby in the same way that
with spears in a lot of ways
up from there I i kinda graduated up typical
a wall fickle pickle
through program I was very few it's been awhile since I've done that pickle was
also cool in a lot of ways
finally landed in the Pearl as my standard language for developing pools
art to help my programming up C pas
awesome job so paroles kinda like to language our job or
and C pas us we're kinda by professional languages that are used to get recoup
real or doc right are about that time was really looking for an alternative
pearl cause I really like for like
really I really love the work done broke but you know walk
it was unreadable and when you grew your Perl code to insert size
it just in scale up a larger problem in my view
ike I could have a pearl a full article rates
so I was looking for alternatives in about that time Dave Thomas
I think it was the extreme programming mailing a mention about this will like
which Paul Rubens so I grew up
Ruby download it compiled on my machine
tried it and in one day I had completely converted over
using Ruby rover for also that was by a doctor and what was great about Ruby
it wasn't hardship Korea did scripting language
and I was already really involved in the whole movement
and are working with that from the Seans
a C pas plus the Java were all the eiffel world
but I want to point out that my or experience up that Prime
is entirely what we call static languages
so my view always very much shape by
the languages that I used to do or not I'm your own little bit a small are you
us no small part that I could reach more 0 red never written any overt
anger so the concept smallpox really work
apart yet that part ruby was her opening things to do in Ruby
I as opposed to like a static language like Java was
was incredible I really love the whole movie experience
there's a saying you can write 4 p.m. coded any language
perhaps the updated version A back should be great Java code in any
language
I think a lot of how many people have come
to Ruby from drop there's a lot of us here
I think when you if ruby is your first introduction to a dynamic 00 language
you're going to bring concepts from Java and C pas
of yep are along a concert for poor or gonna be great and the good work the
whole thing about modular view
up like that's going to come right with that's going to work well but there are
weeks that Ruby that are in
see vocal in Java code
seaport we're going to talk about some of those
techniques that's what I really want to do is if you are boxed
by the language if you think you know I really want to get you thinking
outside about of so
what are you going to expect from the stop
a first-ball I have three examples more or less reliant
code that i'm gonna show you right these are examples library
I've written using the production and some there's one example one that's
just kinda cool idea the reason I'm into that because these examples half before
you have to be interesting and they have to I have to be excited about talking
about
I will make a confession I was working on this presentation
I got to the third example
I was writing up and I was about halfway done
riding up I made this discovery
or I didn't like the exam what was interesting quote
but the process of explaining it wasn't very interesting at all
me so our so I was trying to decide whether
use examples for something else arm
happen you forget save my presentation file sober
few days later when I came back to revisit that the whole that's life
examples both good that's a sign from God
we're changing our example soon be abstract might've read the program was
little bit different but what we're doing here
that's okay the other thing I want to illustrate
art techniques but you're not gonna fine your standard Java
lapses C pas of programs things that
not literally run across performances vans Ruby paw
okay so let's go ahead and move on to the examples
the first one i wanna talk box number one but you wanna jump out
I call this the master up the skies in this is an example that actually
problems
from rake sure most viewer perhaps were to break
I'll bill tool for real thank you
he
summer so i think is the new piece of code UT is the fact that people
user find it useful II that really gives me a thrill more than anything else
people point useful thank you for that this is a actually a very small piece a
break but i wanna talk about it
in rape rick is all about building things and manipulating with the file so
we have a special class
rake campbell's the are
poll watch: in a file named in finding files in your project and
managing up has called the file was stopped use it a lot like this is you
see on the screen
arm you give a claw
a pattern and it will actor as an array
up those filing alike an array
almost there about for differences between
file with them real right number one it to dislike by Paul because
knowledgeable pop knowledgeable about the files so confined those Feilding
uses you can include file exclude files
Dubai patterns an awkward in traffic picked was very knowledgeable about
also specialized to ass this is the big reason
I wrote a specialized of him out because you 2s array
all things getting there your jam together
about space I really wanted it was the bombing speed
what's up file list as a specialized
to us also has a extra that don't exist
a normal right you can manipulate extension although
file believes in the file list you can come in picked up after
other interesting things or file what's that are not available
right finally are
firewood for please the reason is if you have a rate filing have a bunch of
different past
finding your rate filed like the final all
on up filelist up front be uni
operate file that won't be you
but you're justifying just in case you might Mike used by one the fact that
might be
all later so if you initialize
files by lobbying to your file directories a
searching for files building up with the file this could be quite expensive
so great finalists are lazy in the people actually go out and look
filesystem until the first well I'm you need
use the values while at that point would go out
we get the belt bring so if you define
him twenty finalists getting your rate
while not OVA after you anything I'm consuming
a reaction like music that's a would feature a pilot
actually the future were on separate on today
Mike first cut right filelist
looked a lot like yes I so well a finalist is a right
and so on just inherit from a rate and get all the Arabian your
automatically if you come from a static
language like Java or C post loss one of the first rules that you learn in class
design is
do not Eric from concrete piles that carries a whole bunch of baggage with
truth is
that in Ruby the reasons there are reasons for not inherited from concrete
playoff
appeared Priory differ the reasons
to refine job forty walk I will get to what these reasons are so i thought okay
let's let's go ahead and her from Spring Creek last month to see what happens
but actually worked out quite well begin with initialize for file most
such with this is a simple fiber superpipe
Road of your real filelist move or copy that
us but we initialize a finalist by loading the pattern restate the power
we set a resolve flag
of as we have not yet gone out top
the file link that exist files yup also be called Super
that's just good practice with your hair classic visualizer
make sure you love me initializes your
parent classes as well saw
lazy loading sup just remember the pattern
for use later Sep resolve fall so that you
know you have resolve file yup then you have to try to resolve
up and it's pretty straightforward when you call resolve you want to make sure
your revamp the
go through %uh the filesystem get all the patterns
and insert them into
self which is an array and that's not resolved through three hundred-ton
your file is now complete solving file names of a filesystem
and were resolved so the next time you won't have to call resolving
chop-chop later now does this work
one no
up I'll
a getaway we haven't resolved
yet so when we create a file of
and we try to access the first member because we have not resolved
anything yup that arabia's empty so this will pay off
what we have to do actually explicitly resolve
pilots for how painful
I don't wanna you that so way to fix their
is top automatically resolve the file list
the first time you need so we will take indexing operation
and we will replace a res version
with the version that polls with all if we have it was all
Yap and then invokes the Super for
our index what's called you're a pro actual for
indexing from now that's okay for
indexing remember there's a lot up other rate rapid
well so you gotta walk rinse repeat yes
over and over again now you follow
I would strongly recommend at this point just getting a little better programming
make this easier for you to find disposable plates will do that in a
little bit
relieve that as it is for right now okay
im are resolved great after work pretty good
I was really happy to come over rate work exactly like
us am had very few problems them also someone so
reported a BOP this code works
this is the using the plus
operator that
takes to arrays patents the on
together losses about that on a finalist
I was all filers in fact that make the
that guy called me super that would that makes the contents and the result is a
list up
everything the vilest Haas everything and you're right argument we
bus operator so that work but what happens
if I changed or we've got a small problem
array doesn't know
anything about resolving file so in this case the plots
is the operator only regular array regular array takes argument that the
pilots
looks at its sooo
I have a right and it got this far was Eric from a rape
it is a right so itself up let's compare
content well we have no content so the result is just a perforating
only memories all the cockpit the pilots which is about
that's a problem are we going to do about
back pop/rock whites
over that okay
if only up
if only there was a way for arbiter
up indicate the Ruby system all
tree me as if I were to write
wouldn't that be a nice help was then I could put that
into Wild West Ruby would workout
who using some
your or ship
be have the technology turns out there's a method called
who array to kary
that is designed to indicate exactly this behavior it says
I am an awful thank you it says
I am in object and I want to be treated
as if I were an array Ruby senses you happy Mary
effort on your part of it will call that method
use the result method should return to Rees array of saw
will use that result in all its operations or Treat up
as if it were am i right well that's fine
except filelist who
cleverly mimics about effect it
is generating Review looks the pilots is ok
your honor right I don't need the call to hairy on you
I'm just going to use your comp so the fact I can error
from Iranian filelist was what was going so to make the two
a rematch at work I heard modified filelist
not inherit from array after all
step it's a regular object
inheriting from just your basic laptop again the initializes much the same
except now
we looking through actual array object we campaign
inside the file Ste the at items
I love their we have to change or
resolving code arm
so that used to look like this we know
delegate items it's not a cone super
and now everything
is cool we could pay
an array in a fire last that make them releases a walk
I've got object not an array can you after the raid
policy I have a where we are
area on me call that will be happy Ruby does up
we get the result about so that's cool
remember this are we need
our resolve although server go ahead show you what that would look like with
dry out that code that up
implementing all those methods all over again you do something like this
free to list up methods you need to you are resolved
do a little better program music class about
the fight over also pick up actually quite easy would hurt from array
are not appear Arabia
the my all arrays behavior in fact you can
serve explicitly setting up a result pretty much be
is that explicitly listing those even after going asking array of
what are your stats about that and then iterate have just our resolve all those
a little better programming the class program right
exactly quite small so that's what we're doing today were filelist
things to remember from the house okay
some part when you want to be something else is better not true
error but to use the built-in Ruby
up to Harry the case races also
you something similar for spring is a few STR about that but that's something
very
work without so used those rather than arabs
when you want to mimic of okay box number two
doing nothing people have used
builder really don't ask
all what makes me feel good group of more
grover what for library to write
I wrote it just for the pure joy overriding
I saw an example actually room the results include a group that inspired
yes and I we could Ruby quite easily for not be quite
however in the writing abyss a productive so
little or repeat that we had to deal with one another
hawk about those corner cases right now
so if you're not familiar with builder very simple
a builder is a way of building XML very easily
Ruby created over object you then
sir messages such as steam such has made such as phone number
the builder of the best them in blocks appropriately
and builder figures out how to translate all that good stop
it XML using the names of the methods
uses the pact in XML using your block structure to figure out how to best
properly this is a simple example
abusing builder and the names of the pads
and the names of the messages matchup
who the magic about the missing I didn't write builder don't anything about
student
about names about to phone number it's just that we track
those Rapids in a builder but nothing missing
am pick the name and Greek exit million so you can send
anything acting builder and recognizes
really cool I will point after easier right XML with your
that is right up to the love that's about and it's great especially for
dynamically generated up
great rooms generate a list very usually
one stop auto database India builders a really and the
over library use what happens though
this example we have name phone number write a review
all or builder class are to our builder
object Matt Squire 2002 rock
work or walk why I asked us to pay
and he's taking a trip to Ruby obviously
a various defiance he
on what happens when we execute this little piece of double coat right here
yep clients is a predefined ruby has a method called
laugh but every object class refers
possibly up is a number of
wanna number of predefined Rapids you know obvious classes I
the there's to you ask room are
you know the list goes on overwrought use any
these predefined methods in your at some now
builder has a problem with that because it says of predefined doesn't get into
the whole method
missing thing at all and we've got problems
saw wes is pretty far I'm
fix for this would be nice
separate would be nice yeah how can we inherit from
up well actually inherently from of
we would like to be an object but not yet all be
artistic garbage for all the over
extra of comes up up we don't want to
for our overclass so horrible that
well %um builder we're going to change it so instead of returning from a
Pakistani
ever from something hope white slate
whites white I want to talk about
the day
ago
want sleepers out Yuli easy
Iraq
well
almost what happened run you see what I'm doing here
I'm Arabic all the instance methods that are available in the blank slate
Playhouse
I'm iterated you took them I'm on the following that method when you
undefined the map that make it disappear
from that class white slaying will not help
class that will not have I the will not help
house find so we just generate whoever
and remove them what happens when I run this devil forget the right that's a
bell but we also get a little
cup award because we're a little all results removing
about this a couple methods such as underscore item and underscores them
that the system there if you remove them it may
cause serious problems bus these effects
so we'll just under for unless the baby give
I'll actually I think the real for
up like slate we also avoid removing instance about was productive the
balance up
interested that they have a row and
probably not yet a while well
act that was kinda safer to stop
that's pretty cool everyone just we get exactly the right pro
great I love that simple
iraq you rock group
this good enough have recovered all the corner case
but yeah likes like was released pretty much
like that showed the while people began
writing everything papers there's a problem with this October
that these rapids are not appear in my apt to melt even though they show up
go
what are we doing here we require blinks likes a blank slate
lows it removes all methods from internally so now it is a blank slate
and then in are application we decide
wouldn't it be nice to have a globally available method called
Bay we put into kernel her was
model good art anything you define
colonel is available every OPP
what flight now if we could arrange for QoS a blank slate as always the very
last thing
overloaded loaded with at this in the kernel
for loaded like slight likely would handle remove it when it was loaded
unfortunately
it's too late with one wants leaders already loaded
already removed all those methods an hour ago having something to her or
one slick picked up automatically that was not a good day
so get this will result in the wrong number of arguments there
for the same reason to class but does not need is predefined sewer
you with this turns out this is also pretty
you with Ruby are
I'm going to refract wants like just a little bit I'm definitely is a private
method
I wanted evil caught somewhere else or preparation for that we're going
rapid optimum app hi well-used
at the High have gotten I'm the pines all our
methods and no height is available globally
and then we're going to at something to people abuse
about that at added yes itself
hook if Ruby Road saw Ruby
were it the farms method classes models
will work for a map it a
class call method
out and if it's find it will call out
and parents in the name of the map
that was just at artful so
arm I wanna rector arms to
third Lord in method at says whites Lee
Barack when we are about that I want to hide
inside a blank slate if bottles being
added with self you score so if colonel get some
method added to yet remove it from
lights lights or lights like it's probably notification have any methods
yet if you
model we're adding about the two is black pearl that's okay
what purposes only /url it's going to bother up looks like so I
a check to make sure we're only idea if its kernel
the first and last one about the data
is just a way possible health by
up into about that added that we want to make sure that you
all their old as well otherwise we'll liberate their youth
without so that that's good if I think rails has a way of doing that
on efforts up me alias up the check the real
reels has a little way of doing that very hour about such what
year is just being courteous using up
ape-like up please use so pick somewhere yes
saw I'll note at the bottom of the screen says
we need something similar for op read is
who in object because you can at beth is
replica object as well as also up
very several Todd all back
now are we good
how would cover all the qualities I added after
builder release the gap I thought revolt every
everything were who'll can also book
report you get I'm using this method
and its still not showing up builder like
still not forgotten by Axwell referee Arthur said your call because I got
everything covered against up
of a plea we could be missing anything so he sent me the code I looked over
discovered this
very similar the probably
for slightly different in
this case your create new model all capital main
inside model name we define about that
call name and then we model
a the optic class this is actually a very common way of extending core
classes
all the extension any model that pain
extensions event in one place the pork of just before
what's does actually good practice recommended our problems
it probably bypasses
about that having hook because not bad having
rapid are were moving are
it Harbaugh bowl wats up that saw
fortunately for us okay appeals there
fortunately for us there's a
hook feature call and feature another
gonna walk this code as a solving that the data
almost exactly like that we have to make sure
whenever we Blue Bottle ok apparently just is called whenever a broad
so we could fine those events we check to see
are that were worthy of it by Afghan we remove all the methods go ahead
i'd better that model it looks like so
white like ap his wallet that has turned out to be pretty good that's what we're
using
currently in over I don't think I've got any reports from many walks like they're
having problems
all look her we r knows where you have good putt putt
but if you want to see the exact details like for you to go grab hold for builder
prove that it was a really fun library to write really applaud
back
this is the example but not every library
I think the techniques your interested I'm really hoping someone will find a
good use for example probably not
about being a good use or arms about
the technique is fun that's good enough for me I like pop Funko
use enough
right israel's boat you done any real programming all
you've seen this all the time user is a reels
rather record artful
R O and has a fine about the mall
rethink fine all users me
is chip and you see
am if you want to be a say that's interesting
we have made it was perfect Markham quotes
that is actually sequel for mixing
little bit asleep code with the little bit Aruba cold all kinda mean one thing:
its its the whole 73 where the
puny think is is bothering at this point cock
one thing I know I could do if I have a list use
I think also what on passable walk
end up walking okay it does is used a Jim
here should be 8ee all their
edifice equals
here that is true and select for me
all users who main this was
used letters whole Ruby code and that's the way we're a group photo every day
ever walk
novice see all-star that we have to be a so it's also
I ruling drawn to the what we are doing things but
another database is therefore models are happy that somehow
but would if wouldn't it be nice
yup there's a wave useful app
if record that would be so cool
so we could think this users of the lock give up what the hell's our criteria
we quote everything Ruby everything would be beautiful and we're all happy
never have your seaport yeah so it looks like
or writes a lot here's my first
tapped I
here some cough move from the audience depicts the problems with this poem
a folder
work pretty
for of
hot no for
okay its hugely inefficient what what what I'm doing I'm
grabbing all the users from the database and they're not putting the
analyst so I have a million users I just having
array with a million entries in nice or who have for the him for users
whose name is actually jim not really
efficient not official all its low
marked people's love it after would kill disco your databases are actually
as much as I really if they basically are think they do things
very well be have really efficient algorithms for searching
data in the table a indices set up the practice of
at work using database up all for this
just for the sake of being able right up group so
got up got this problem want to do everything Ruby
but I also want to take advantage database as well saw what can we do
well I'm gonna hypothesize
a magic implementation up for what and the magic he is OK
we have this little magic method called translate block
we pass up the block it will come up
the resolve this method will be
a condition we can pass into rails
and real and sequel and the database
all the good work that it lights or presley the former towards
and then the database does its job we're still
writing everything that we do Ruby that would be really cool
so I would
well I could think of
ample avoid my property we could actually part that quote how many people
have written
the par-4 great
was a lot of fun
are for ya probably was but also a lot of work
just to solve the problem right for writing a rooftop
that's just how many people have written a Ruby park
perhaps word
you that's a hard thing to do
ruby is an interesting like with part that after I think performers up there
that that will handle some about for
pool work
for me because I i'm looking for the simple right in the evening well
oh yeah this is this is what rock this is a small strip
a coat from the Ruby parser noted review itself so
I couldn't get in there there's a library call parth
ass here on for war
hip bypasses the whole out like are
requested by say what there's one soco the
really really really knows how to are through be thats Ruby
so what's what Ruby parce and we'll go into
its gots Andrew lipow the abstract are bbbbb are
the par-3 that's built into Ruby itself wats pose a
into rebuke who and it's a really cool like
yup I really recommend doing that factors such a good idea
someone else had that idea up and if you look up to him
mission project are terrible blog this URL
he does exactly that fact he writes a berth lock
using par-3 to get up-to-date up so
if you want to do this is a good way to go and look at that library I think with
I'm going to start up for all users were it's really quite yet but we're not
going to do it that way
me because someone else is doing it but of Pau
why don't we just execute code
all XQ
Co what's gonna happen keep that bought mine for just a second
and this is a I R P such for your
limitation star RB we load
a Weiber called I no on I create another cop
people so we're going to be dealing with no table node is a
whip are you a little bit 10 yes the table node is the No
remember a database so we talked to remember the name up
users which is the baby over database table
backs are record all restore that in a variable called
user and then we
whole about that or user method is .name
restore the result about that in a variable call result
Reprod up all I would convert result was throwing
recap users got me
that's really interesting
I created on our I call the method on top
the result of calling wrap it up like Britain result own
through it tells me what level I call
one topic but all actually it
act but does something a little bit different
for it ver that method call
user to see all right references the tabletop
cool
I can go yet feel
reference from within just by using the stable though
and just to illustrate farther I also ask for 8 field user
want to convert the resulting back to a string I get users
now a so I can reference I can build up sequel
for a very simple method all and your publication the people know
is trivial it's one its two classes the first one is people vote which were
using directly
it just remembers the name of the papal that were referencing
and when you convert back to restrain
there the bottom of the screen you see that it just returns the papal main
trivial Co only minor tricky stuff in it at all
is about the missing call and when we yep
a method or are people know that sells
I am going to remember map it was just
all by creating a new opera calling map it would
the method noble recall me able note
possum up that was just called on me Richard that
as resolve the matter call itself and so the
method no is the resolve calling about the daughter Ruby object
his method no again really trivial
which is reports the Opera the method name and when asked to convert to a
string
does exactly that the app is all a coat the
implement RRP session ask who'll
were Parkway converting grupo
see cover method called
objects to see or fragments reference
your or arm people's
but to be a little bit more just for
your reference are here but worth
how do we say usually equals Jim how to record that
approves like that into sequel
well you know walk double eagles is just about the
an I could be five EE also no
I can see something this violent worth or
and I can create a new I don't know
with that you're gonna see a lot of different note flap implementation
all the binary op know who did the binary opto
was looking for double equals seaport will look
up that would be a single all and I have to remember the left hand side on the
right hand side
up also a record that we initialize
or have children implementation by Marriott or
record the operator the left right hand side
have been weak US the whole thing we just convert it to a
see or fragment that have currencies around the we'll have to worry about
going back for upper and we have the
left hand side revert to a string operator converted to string
and the right now it's like bird just right
Wow Barnardo back by Yuri of know it was
the you as well about very so
reiterating capture the method
in the note buyouts greedy note of it represents a
miss lies that note of liquid things that it needs to go
just return the app implementing the note is pretty trivial
and running this now greater cable though
we execute code user H equals fifty
and store that address walk
room convert res 12 string it says
users got a you see all
where clause up Ruby pro
right there try to get let's do the same thing with mister now lets a user dot
mainly was Jim
government will jump and when we convert their the result of that most rain we
get. users not made
single people jump who
I got a prop
yeah we have no quotes Roger ap
with easily that small matter program
what we've done is that we're not think which we're taking Ruby African just
don't
about a string up really good
differentiate conversion we need to capture converse Ruby objects
the sea block numbers just
US on a number that's fine over string recover reviews true
to AC of rag really wanna put both the route
so we need to surprise Perino class for those
was pretty liberal no playoffs and that's just handle simple things like
integer
burt directly at the sequel and then we'll create
a string node that handles rivers and streams in the sequel strings it does a
when hope you have pictures at single quote you cite strike
probably wanna make that a little bit fancier Campbell
all so thus keeping that string as well
be aware about but we're keeping it simple here
now we have a problem
I've got a bunch of different well got last
literal string but I have to make sure like right
Ruby up we have to look at a Ruby up
we have to make a decision artwork by that Ruby object
and come up with right kinda Ruby op
we could do this I could create a method called rapido
takes an article from looking statements you know
BAP and this will work fine
arm I don't like this your
reason yes I've got a wonderful over
which objects know how babe himself
things quite alright ask centralizing all discover
the one place 10 it distributed one we object to every
object knows how to convert itself into it sequel
no so why would rather do something like this
open up object class creepy
as a sequel note up and it is wrapped in ER preoptic
as a liberal no min string which is a special place I wanted
Bowl I just rap strings Op
any string no and recover that as well they're both coal
as a sequel the key is we're opening up
core classes your wanna be purple with the bay up
this is perfectly fine Ruby but whatever
careful because your opening up for classes at the Community
with like so that's widening the
as AC what no talk hope that name was
unique about that I probably would collide with any other
arbitrary review library attic big sister
up just be aware that if you
up and now converting any object to me
no is really really easy just after up
gimme yourself as the proper no
only did it worked with no little bit it needs its own as a sequel
no about that this is already a node
this report itself that works out for what part mean we need to use this
when we create in binary of
I'll no we need to make sure that be
right hand side up the operation converter
at the left hand side is a note of already that's why we're here
Expo we don't need convert self it's already have no
other may or may not be ago just convert would know
now when we run this
single quotes that's really cool
we can convert Arbor Peru biko to sequel
just for executing the rupee Co
okay ok love to be with us example well
there's lots of operators we need to patch up the leak was not the only one
we need to hit all the other
greater than life I'm a grew equal to
people to all the of Minas
star provide operators and a bunch of other operators you might want to
consider
on things like no question mark
no question mark was the rubidium for doing that perhaps note
pic no Corp marker like that you is
naw okay so there's up perhaps
pattern matching should be converted the sequel like
operator maybe maybe not I don't know.
was all kinds of things that we could at the apt been if we wanna write somewhat
it's pretty much just this supply north africa
you to ask all our people up result wat
take the block we execute the ball passing year
eight people know object as the
all as the argument so would we evaluate our condition the condition that the
value we did against
the people or objects builds up a sequel called
as we build right weary when we're done that result car
we take it converted to string which I for got put into the slight
and passed it to fund all we've got are
selector we got our magic ver to
are report to sequel
cool so why don't we do this
or problem well there's a number up
most operators are from our community up
so we can see user not name is Jim or we can see Jim
probably was user got a the first would work
certainly has a small problem that double equals is being stepped through
the Strait
wire during doesn't know about 20
so it's going to return true or false it's not going to refer
for proper note of it after that so bad is the problem can't play with that
override are double equals
and capture the app that we're playing were all
really fundamental depositions Ruby I'm that are
all that so battles
that's a small problem either solver site were actually if you have
mathematical operators like plus mines
both actually payable are the whole
coercion problem by I a protocol called
or so in Ruby if you have a pics no
41 yeah at the gather have to figure out what
crop result for those things participated warm-up
or worth figures up rock of past do that
you actually are you over here use
in Bow and make sure that notice on the right hand or left their flights the
work
up so mathematical operators are okay
some of them such as double artwork right
as a corpus work
but here's a bigger problem I think this is really the killer
that really stop suspected to be useful for sequel
and that's the double in person and a double work
a bar operators or
well not about you cannot override them the reason is
that double am double vertical are and the
or operator short-circuit
their evaluation they can determine the true
true or false overexpression just by looking at birth of around
you ever valuing second I'll
those difficult to find that program semantics any
about that there for Ruby does give us away hooking into
those operators as override you cannot overwrite
double am double vertical bar
up you could use going single critical parts that
then we have to write special Ruby old cycle select walk rather
record that's a little bit a comfortable for me
a bigger problem also is that a but not bang operator
be back of greater all sort of override
you never say not addition always say bank in ethics Prof
for true or false it will never think that
bird not no is no way of doing that
all like whites for
can't change can overwrite so that's a problem
and so I would really recommend this technique for a sequel it's a great
example
kinda motivate the problem but I'm kinda throwing this out
really hoping someone will have a great idea for using the I think the beautiful
part
up it's a solution or working for problem perhaps
all maybe evaluating expressions and
rafik are some a mathematical analysis useful
maybe you have a problem in Cuero able to be really useful
you but technique is happen room
code execution Tracy markets call and building up a structure about
hell what's happened in the past arm
actually use this very mall limited way
influx law what's marked with the ability Rick or
all transactions as they happen on the box awaited
playback you have a verified
good way of doing something and a new way of doing something
verify that the in Iraq law a very limited
half bath up upping like
arm I got this idea actually from a small
like war which does this
smallpox very similar is also a library in ruby port part
Syria does this as well suffers from the problem
you've mentioned before you look close
saw
advance Ruby class design what we were always follow up on code
that was actually my goal for today I think we really should know about that
that language shapes the way you think that when your roomie
work or ruble fight solutions to your problem and in doing so you will perhaps
understand the corners of your life you coming to Ruby
from Java for C pas also from a different language a news Ruby
very quickly but Appling were those or repeat
what weapons or learn about meta programming to learn about redefining
operators
you're gonna miss law up good solutions
your problems to you can't get that or language
all your belts are really encourage you to you
going research language under spam was paid orders
also wanna courage go ahead
outside the box work for those unusual
our solutions you don't need them all the time that don't need them
both both pro-growth like this I would be very
very word but there are occasions when needing special solution
Ruby up in a fine that's possible solution for you so go ahead
think outside the box your cock after all up three years ago someone had
not stopped all the POC with regard to web frameworks
Arts will be right this kind of boat
so thank you very much

LA Ruby Conf 2014 - I Have Pair Programmed for 27,000 Hours: Ask Me Anything!

dude in mmm
the I know that a
knows talk so there's a lot of audience participation
kinda awkward held like somebody asked for if anybody has a questioner to raise
their hand at something there but it kinda Mills around
well guess what this entire talk is only that
so nobody asks any questions
it's going to be really awkward for everybody
so let's do this and give you a second so i pair program for
27,000 hours which is about every working day will
more or less for thirteen years and
I really want you to ask me anything because people find this topic
fasting something to give you a moment couple seconds to
just silence think one
question you might want to ask go
okay that question you thought it was by one of the top three or five questions
that though that one out
and think of another question
that you might wanna ask how do you get up get up
up you're going for it awesome how do you get over being nervous
let's do this picture how to get over being nervous when europe a program
where somebody
um having a lotta time doing that a lot
that makes a big difference that first time is always
the first time you've ever paired with somebody and even now after 13 years the
first time out there was somebody
I'm nervous and I'll even admit that
you know we organize our our projects and to these
work on stories in calling cards whatever little features
and whenever I'm about to start a feature with somebody
that may last a day or two even if I work for this person for a long time
I'm nervous when we click that starr because I'm always thinking like this
could be the time
when I completely fall apart and turns out I don't know
what I'm doing and the person I'm working with this guy I think I'm an
idiot
I it happens like just for a few moments
it always happens I think for me the answer is I never stop getting nervous
but you it's it it becomes just kinda part of it
and you get over it really quickly especially when you have a good report
with people
%uh there's a question the back no stupid questions
yes what is
pair programming i in general- so
maybe I'll force you to ask another question raise your hand
if you've ever pay program but
almost everybody I would say that was eighty
ninety percent me I'm so for the temperature left
pair programming is a supper development technique
by which to programmers although it can be
a program and a designer it could be two people to say that
are working on the same computer gotta go computer
stopping the same software problem at the same time
so sometimes that's literally to
people sitting side by side at the same computer with two keyboards usually
I trying to decide you know how to write this line a code grey here whether or
not we should
go take a different direction whether or not a
should we follow these solid principles that we just learned about
about how to better follow them and kinda constantly working together
to come up with the best solution to whatever whatever problem you're solving
at the moment
I'm sometimes you can do this remotely tissue doesn't have to be at the same
computer you can do it across
screen sharing and and such as well let's go to the canonical
a description of what pair programming is and there's a lot of benefits as well
but there's a question so I'm not gonna pass it up with for
what is pair programming good for
and was pair programming bad for a
so we tend to believe I say
on a bus Asami I believe but there's almost no problems that are bad
prepare programming um we
even pair write this gonna sound weird but it makes sense to promise
we sometimes pair right emails on
especially for example you are sending an email
to maybe a politically sensitive up
a manager or something like that when you're may be working in a complex
organization
where the only everything is email all the time
and you're trying to yo capture well some kinda situation
all right that together so that we come up with like something really good
ever that sounds kinda weird but will even take it that far now question I
have heard
is can you pay program on those sorta boo
sorry a split re I am
I just some point this thing
on let me put this power imbalance a while I'm doing that
i havent had I've had people ask me what about the kind of cortical
artsy things or the algorithms and
that kinda superstar those those things that traditionally are thought others to
we know where you go to a mountaintop you think about for a long time and you
come up with like
Google search algorithm or something like that I think you compare program
on those as well um
a I really don't think that there's are the anything you capture
bear
and you care program with out talking to each other so I actually know somebody
who'd on Twitter are tweeted the other day
but Remo care program remote programming is so hard
and iRobot at all what kind of problems are you having site passion about that
particular topic and I like to help
is as well you know when you can talk to each other it's hard to know what's
going on
like well it's really really hard to pair programming without talking
I can also say I've never are programmed in style
a comeback that person who won't talk at a different problem
I can talk about that but as far as a
literally having no means a verbal communication I've never
done that I don't think it would work very well
have you done this
I'll that's interesting having your could speak for itself I like
the philosophy about as an experiment
I have a hard time justifying Billy my clients for that experiment
the I thought something I
you haven't tools for remote purple
I yeah so what are the tools for remote pair programming
I have a whole talk I could adjust about that the whole go too deep into it
but in general you need some kind of
Voice communication Skype Google hangout something like that
their screen share any need some kinda screen chain technology
by which you can clap rate on the same computer to solve same problem now I am
opinionated about what about to say love people might not agree with me about
this but I will say it anyway
and that is people often say like I remote program and we use Skype
or use Google Hangouts and I say you're not
pair programming I'm sorry you're certainly collaborating
ferry you know intently on the same problem
you not pair programming because you can't both program
that's my king writer
what happens when you don't agree a what on how to proceed with your pair
presumably maybe in a technical you know anything anything anything from
programming to
any kind of approach that happens all the time um
but the talks call pair programming kinda
continuous compromise and negotiation
um but I also like to say that what you often arrive at is
the highest common denominator at the lowest to the highest
to take so when you don't agree BL
spent some time talking about of course sometimes
you won't you after will say 5-10 minutes
may be able extremely passionate about these two directions
what will often do and we can almost always do this
is bringing another person who is respected by both
to say listen listen to this
um and if that's not possible maybe your to people you're gone
an open source project or two-person project and there's nobody to bring in
on sometimes you just have to go with one of them
and somebody else has to just take just kinda grin and bear it for a while
and see if it bears fruit see if it works out
but the other person the person according to one
should ideally be gracious enough to say if they're idea doesn't end up working
out
to say let's try the other one maybe you'll good tribal
as well um
non-verbal communication methods that use with pair programming
others are especially important with Remo pair programming
where you up against each others hands and such
but actually I find that I'll a lot of people talk about
we'll ask me how do people how do you decide when
who's going to what he calls a drive verses
navigator had a setback and not have has a keyboard because what I'm not talking
about
is like one person running like a left-hand side the caber
the other one the right I did actually as attention to my attention
ask my ok I got a haircut the other day before I can asked the lady
work in my hair if if she could imagine to barbers
working on the same had had the same time and she said no
because their scissors would keep hitting each other a.m.
thought that was interesting I'm not talking about that about the
so there is like a I'll ideally in a good parent situation
a trade of the happens you know as your working on persons like it a little
while the other one takes over that one takes over
and chemical bounce back and forth and a lot that I find is that non
it's done on purple communication happens and it's little things
that you get used to picking up on somebody's like
up dude on this computer here and try to me you know one person who's driving
there leaning forward the intently
typing like clearly in there there eyes are focused a clearly like very much in
his own
and in that situation it could be very disruptive for the other person just
jump in and grab the mouse and keyboard to start doing something because
we've all had somebody rip us out that zone
and it's very disruptive now that person is doing that and then they pause
and then they do this thing like
harder how do you is it
is a the method on kernel and thats
when the other person can say like I know what that is
and they can jump they can jump in because they've the person has taken
themselves
out about Sam and
the other person can almost always jump it without disrupting that without
disrupting them
out now you there are little techniques we can talk about where somebody refuses
to give up the keyboard
um DVD is great for this because you can do something helping pump rainwear
on person right to test and output per cent implements and then
you trade back and forth that's like ever a good technique to
enforce that um but those little nonverbal things your people taking a
pause sitting back
rubbing their face there's always this on this is my paper on
this is a I'm not typing right now
people do that on a lot that's %uh invitation for somebody else to take
over as well
something over here
I'm so the question was other situations our people said
that remote pairing can be even better than in person paying
and sent that the actual question because I've actually I heard people say
that they
sometimes enjoy remote pairing more than in person paying
and I am biased because I remote pay program full-time
so I'm biased alike want people to say that
but I'd uninvited people have said this and the reason they've said
that our way to an example applied it's that is that
when you're saying it is a busy office like the travel office
with a lot of stuff going on and everybody is pain because pain as a lot
of talking
its there's a lot of stuff going on and then that person like through that Nerf
ball across the room and then
you know somebody is having a birthday over here and as just a lot of stuff
going on
um and remote pairing tends to
focus you even more focus than you already are
when you're carrying because pain can be extremely focusing Sony
you know if you can to put on a headset I'm going over your ears
and your we are looking at camera with this other person's face on and you're
working on this code together
it can really laser focus UN on the problems are you trying to solve
and so for that reason some people said some situations they prefer Remo K
because I really focuses that I'm versus the kind of the distractions that can be
quote-unquote normal office and in
in the back
up good question so if you are pairing with somebody
who is very senior to yourself
perhaps um do you both do the
does the pair in general get benefit gala
so I say absolutely I think one other core
benefits a pair programming is the cross training and knowledge transfer
affect up now that might seem like it's all this junior person
getting all about benefit um
and I find that that's not the case at all the senior person Assamese been
doing this for twenty years
and the pain is somebody kinda somebody who's like a college grad I
extreme but I can say is somebody has been doing this for 15 years
and recently was pain with the college grad
every single day I learned something from
that college grad that I didn't already know and i actually this is this is no
liability notebook
all day planner i sat next to me on my desk and everyday I write down something
that I learn
for my pair and it doesn't matter if their senior more senior than me
same level recent college grad I always learn something from them
so I really do think that but that's one aspect by which
a very diverse pair will call it our despair
um can still benefit each other and also find
well let me ask you guys this question you can think about yourself I say I
find
that when I really think I know something really well
and that new be says what's going on here can you explain it
and I explain it and they like I really I still don't get it and then I have to
force myself to
actually understand it better and not make all these assumptions
and I've actually managed to talk myself out
a belief that had like actually saying them out loud I realize
Heights I kinda sounds terrible
why are we doing it that way ever have those moments I have those moments
so that's another way in which just that the
the forcing the %uh the the senior person to
to get into a teaching mindset can benefit them
as the teacher as much as it benefits the person whose line
I
Mikes by so the question was would people who've only
paired side by side in person somebody then does remote her
what has been their general take away and I would say almost every single time
they've said that it was almost exactly like in person
not necessarily better mean I say I bet if you were to like put it on a 100
point scale they probably rank it
lower than in person paying and I would never go so far as to say like
I ever to go home and my headset and some high speed internet just stay home
life I had a choice I would be side by side pain with
the people that I work with so you get so much higher fidelity everything
but back to your question people almost universally say that it was
way better than expected that is intimidating is like
technology going on at like some kinda blurry video and
it's like what's gonna happen I've never done this before it like
%uh the screen is typing on its own and I am
the novelty love the remote
situation I'd say falls away very quickly
like by within an hour or less and because once you get into that zone at
like
okay well should we extracted object here or or not
and then use you just revert right back into the normal conversations you have
all the time a pack
and whether or not that person is the composition having is with the remote
person or not
it's the same conversation and it's the same at the inflow
I love the parent experience %uh as long as you
male have a good at high speed and internet things like that
I'm some people usually say that's really good
a with
do I ever want to just work by myself
and the answer is yes yes I do hi
my name's Joe pair program pretty much high-tech rare
and I still really sometimes miss working by myself
um at the it is a different experience
you know I'm a plus but I got this light
didn't have any questions about the words on here
I a.m. %uh so yes
I do miss working by myself sometimes and there are times
like the way our company structure sometimes you're in between
client engagements and you might have a few days were just makes more sense you
to work
a work by yourself I've had people ask me a
so if you're if you are exclusively pair programming near Paris sick do you just
take the day off to
the call that we're not in were not like that dogmatic
help crack and I'll send people home because somebody has a
you know cuz they're pair has a cold or something like that and those days are
I'm not gonna lie
it's really fun and I can also honestly say
I a check into my worst code during those days
and make dumb mistakes and thrash on these easy things that
my a pair with just like what you doing
like its you're you're making a mistake right here so it's fun
but its order they like when my wife is getting is outta town for a few days
kinda like bachelor time stay up late
and you know drink that one extra beer and things like that but
you know in the end it's better to go back to more discipline say
are here pusher
to the question was
what if you have a parent situation where people are also the same mind
you know they agree on everything that the same experience level
there's very little interchange %uh via ideas our knowledge because they're
basically on the same page
I I found that that's extremely rare situation
because were all extremely opinionated people
and we have up I even more
like maybe that maybe wasn't as fair as it is to say
people that have different experiences
from their past different projects different companies it may be different
if two people I say
hired on the same day straight at a college or something like that kinda
come up
together only working together on the same projects you know that maybe
a situation where it might be more likely for them to
have had this group think you know total lock and up ideas
because they both had such a narrowband experience
but in my experience that's even people who are the same a to graduate college
at the same time it worked as a similar companies before
working together all that other experiences
have come built them in two different people with different ideas
and and have a lot to contribute to each other
so I can imagine that situation happening but I would imagine
it also be an extremely rare and they're almost always been an IK
interchange ideas between almost
any pain nomination experts a
pressure ever
oh oh boy the editor what editor do you use
what key mappings to use hot damn 24 ac
um the um
so the answer is yes all the time um
even amongst you know petals kinda famous for being dogmatic about things
like key mapping and their bodies in the same editor
the Gaslight different officers years difference editors um
thanking mappings and such %uh so the
it back it up with a hike in a match at the No a bigger issue and say open
source situation
hey you wanna work on some open source okay that's great okay
now we're kinda but we ever has our custom tuned laptop
just for them um if somebody really wants to learn
other editor that that's a great opportunity to do so
are your day max percent in November San you know this is a great
opportunity for me to learn a he Max or office are all set um
at the very least bought finding the default settings on those editors
like cedar overwrite all up the defaults guy like reverting back to the default
on a lot of these editors can help
because the other person they may not know your custom thing but they know
the default so whatever the editor are whatever the editor is
I'm so like finding some compromise I can be great
is also good opportunity for you both to use something you're not familiar with
and you can both are not together us to the side
re: a I'll
yes I I think the question is like how do you
decide kinda how much driving one person does versus somebody else you like to
you
to switch off the the typing every few minutes
are a few hours are maybe somebody all types all day long and other processed
on the next
today I would say um
this is going to sound a little squishy but
kinda whatever works out great for the pair within
within limits so for example out by Never Say acceptance
weird situation like something has I used to work somebody had our site
literally could not type
yes pair programming with somebody who it's physically on cable incapable of
typing
um so 70 situations I would say that going all day
with i mean somebody pair pretty unbalanced um
down to the other extreme like you trade letters too far
a I find it yelps basically be a
every kinda few minutes I like there can be
I'll you can use things like campaign to enforce
up below in a situation that would go on balance up without it
at the person is just a keyboard haha that is not going to give up the key
worked as a
I got the typing so much fun um and then the other pic until like hey what he
says I thought well it's also have a little
non-confrontational cue
at like hey maybe we should ping pong this one on that %uh KIII get
a message on my hands down um so that can be a good way to bringing the
flowback
but like like there's a there was a a question earlier about non-verbal
communication and
and I kinda turned it into how the flow works out and just those little
people people go through a peaks and valleys big ones throughout the day like
maybe you had breakfast in your like
and your coffee near up here and then it's like help 15 minutes before lunch
in your kinda like
will struggling and then of course is that to those I like three o'clock
were like Bruno you a dislike really really working on your pretty hard
and you're like feeling like you're gonna fall asleep but your
inevitably people's rhythms
are all they're not going to be locked directly and aunt as
as far as like the energy level psychadelic
writing the peaks so somebody's like really into it and then they can to take
a little pas in their thinking
and that's a great opportunity in a good healthy pairing scenario where the other
person can to jump in
and my and my experience that every has to be every
few minutes sometimes five sometimes 10 sometimes too hope that answers your
question
I the other guy didn't get to talk earlier
okay
couple couple questions there I'm one I
it and an effort to sort a balance the pair see don't have
too many kinda Bob either
experience levels are exactly the same or totally wide-ranging ones
do you ever do we ever say try to mix up the pair specifically to pare people
together
I am purposefully like a
so they short answer is yes we sometimes will do that especially when it's
something like a
hey John is really get a CSS with the CSS chore
coming up I add hey you know Sally
you really don't know any CSS is you but you said you want to learn
love how about if you guys parabens somebody color
arm or when somebody is not working on say that's one area the code lot
and had become there's which is a kinda
a danger um being getting
rotating people through that a expert rapidly
so that they can transfer get that not get that knowledge shared among stressed
that he will do that on purpose as well
a secondary question was how do you decide when
people are gonna pair um and a
couple answer to that one we as part of our morning
kinda stand-up meeting morning meeting I'll check n
we say who what's the switch pairs we try to switch every day if we can
up 10+2 structure our projects
such that the thing you're working on are these little
thats that you can often get done in a day so that's a great opportunity to
change like a we just finished that thing on the profile page I'm done
we're done with that let's mix it up to finish something yesterday okay let's
trade I
sometimes I have people who need to stick together for a few days
and that this time um
now %um but the officer can happen where
maybe this is really long running feature super complex
these two people that working together for three days I
idea that like managed to convince people to let them go for days I'd at
and they're still together and still not done we usually will
encourage them to break up and get another mind the next that usually means
are stuck on something
or that the stuff they're working on a so complex that we need to get some
other
ideas and mind to those are all
ways in which we decide how to combine pairs
right cross training different disciplines like
sis ops and programming I might turn that into
I bringing those pain designers a pain with your product manager
I I love that
i'm for many reasons wonder is the
the easy way no like cross cross-training
somebody's not very good Asus of their pain with SS ops percent
they're both gonna learn a lot from each other up
but the also I feel like the secondary benefit up the cacophony these camps
the il's of guys out there like
the yeah %uh those designers
way Photoshop with that um
it so pairing can also bring together these other people
and a turns out we're all pretty much the same for all
Kiki people and would like to learn from each other and
it's a pain can break down those kinda social barriers as well
so there's literally yes cross-training now something I haven't necessarily seen
as
full-time pairing between these different organizations like
you always have a programmer always paired with a sense of person
um those tend to be more targeted things like able
you got to deploy to that server and I T kinda owns that
but hey let's work together on getting this working because I tease ever
deployed
that thing you're trying to deploy does and does a great targeted
situations to to care
I think we have time for maybe Wahine more way in the back when should you not
care
all I got 45 seconds um that's that's a
that's that's a tough that's a tough question I'll think there's anyone
situation like you know definitely
in the pair programming handbook online you know fifty it says don't care the
situation
um yeah maybe I'll
changer question in till like I
make sure that you take breaks if you are getting burned out on pain
I don't think it's necessarily a bad thing to say like I just celos de
um other tasks that shouldn't be paired on
I don't necessarily think so think you know you may find something
by Tom a to make sure that you you take breaks throughout the day
so you can kind of take a break from this intense situation
and then 17 once in a while you may not want to
you might want to take a break from caring altogether just assertive
take a break from that ultra intense
interaction you may need a break and I think that's ok and I think that that's
time does anybody have any questions thank you
the
well
the
the
the come

Tuesday, September 27, 2016

The scientific method is crap: Teman Cooke at TEDxLancaster

the scientific method sucks
now by that I don't mean that science sucks as a physicist I believe that
science has had countless benefits for Humanity
but when I was in eighth grade I learned about this thing called the scientific
method and since then i have done science
i have worked with other scientists and I've taught science to college students
to K through 12 teachers and two seventh graders middle schoolers and from these
experiences i've come to the conclusion that the scientific method sucks
if it's been a while for you as it has been for me since middle school
let me run through it real quick for you first of all
step one identify a problem step to do some research
step 3 form a hypothesis step 4 do an experiment with some independent
dependent variables to test your hypothesis that five analyze data
step 6 draw a conclusion it sounds good right
it certainly matches what we see on TV and in movies and what we see on the
news
unfortunately it completely misrepresents what scientists do and
what science is all about and this manifest in four main ways
first of all it's incredibly linear we start with a problem statement and we
end with a conclusion
this implies that science is something that's once and done fixed for all time
secondly it's not very intuitive
how do I choose a problem what do i do with my conclusion when i'm done if I
have no idea what should or even could happen
how do i come up with a hypothesis this makes the process intimidating and
dangerous
three there's a focus on conclusion reaching the conclusion on getting a
fact
well what happens when the information changes what happens when facts change
how does this process can
sure that and finally the focus on experimentation
now don't get me wrong i'm a big fan of teaching students to control for
whatever random variables they can but there's been a lot of really good
science that's been done without being able to control for a while
anything for a moment I'd like for you to imagine what budget
it would take to create a laboratory here on earth to study the interior of
Jupiter or 24 much star from scratch or to study the galaxies development
you want your tax dollars to go toward that
now you may be thinking oh it's probably not that bad at all
we've trained generations of scientists using the scientific method myself
included
surely i'm exaggerating
well let me walk through a few statistics with you
sixty-five percent of Americans have little to no idea what scientists do on
a day-to-day basis
fifty percent of them however have considered it
whatever it is dangerous thirty-two percent of middle schoolers of 8th
graders score at or above proficient see in science in 2011
the good news is that's up from thirty percent in 2009
the bad news is that implies that sixty-eight percent two-thirds middle
schoolers score below proficiency
thirty percent of elementary school teachers Phil well prepared to teach
science
now that's compared to fifty two percent you feel well prepared to teach social
studies
sixty-six percent who you're well prepared to teach mathematics and
seventy-seven percent who feel well prepared to teach reading and language
arts but here's my favorite statistic of all the one I find most telling of two
thousand parents surveyed in the UK fifty percent said that they feared
answering their children's questions about science questions like why is the
sky blue
and why is the moon out during the daytime
twenty percent one in five said that in response to such questions
they said no one knows or made something up
this concerns me as a culture as a civilization we fear science-y well I
believe there are three main sources of that first of all that working we're
obsessed with right answers we're obsessed with conclusions and as we go
further and further we learn more and more stuff we can't keep track of it all
in addition the fact those conclusions change
let me give you an example if you're like me when you were growing up there
were nine planets in the solar system in 2006 one of these things was eliminated
which brings me to my third point why
we don't understand how these decisions get made
we don't understand the thought process behind it now all of these problems
possibly don't lie of the feet of the scientific method but it's not helping
there is however a better way
let me introduce you to the cycle of scientific thinking this starts with
interesting observations
what counts is interesting well if you find yourself asking the question what
happened there
why did that occur what's going on
it's probably interested in the face of such questions
the human brain does an amazing thing it tries to come up with an answer
a story an explanation of what's going on
now a lot of people are perfectly happy to have an answer but scientists and
this is what makes scientists different from other people scientists want to
know if their answer is right and the way they do that is by saying well if my
explanation is true it is correct then I should also see this
they make a prediction and once you have a prediction the only thing left to do
is to go make-up observations to see if you are right and if you are but if
you're not if you're truly lucky and you got it wrong then that's going to bring
up more questions questions that require more explanation which leads to new
predictions and so on and so on and so on
no why
is this better well first of all it actually represents what scientists do
in fact postgraduate education and science is all about teaching people how
to take interesting observations ask pertinent questions and then develop
explanations that lead to observable predictions
this is science but secondly and more importantly it's much more intuitive and
much more engaging the power is in your hands
once you have an interesting question do you want to go to the library and read
up on other people's answers or do you want to skip all that and come up with
an answer of your own and see if you can make a prediction and test it
it's up to you that makes it much less intimidating from this as well it
becomes much more obvious how examples how explanations change over time
in fact there are only three possible things that can happen to a scientific
model
it makes the right predictions in which case it becomes stronger over time it
makes a few wrong predictions in which case it is modified over time or it
makes completely wrong predictions in which case it will be abandoned
over time the last great thing about this model is that it also eliminates
something that's very dear to my heart
the idea that any explanation must be able to be proven false and to explain
this i want to start with what would it take for me to show that my explanation
of the phenomenon is true with a capital T if it's true then every prediction it
makes should match the observations
how do i check that I have to check every observation
that's not every observation that i can make with my current budget that's not
every observation that i can make here in this amount of time that I have
it's every observation everywhere every win
it's not possible in order to prove
an explanation false however all i have to do is find out that it makes the
wrong predictions and then make sure that I didn't make a mistake
the way I think of this is to say if you give me a model that consistently
predicts the wrong thing i can say with certainty your model is wrong if you
give me a model that consistently predicts the right thing i can say with
certainty that your model is not wrong yet
let me give you an example in 1781
we found the planet Uranus but it did this really weird thing at certain
points in its orbit
it was further along than we expected based upon our models are understanding
of gravity and the other point in its orbit it hadn't traveled far enough
it was almost as if it was traveling too fast at some point and not fast enough
at other points astronomers looked at this and they said you know it looks a
lot like something is pulling it pulling it a little bit faster or a little bit
slower depending on where it is in its orbit
maybe there's a planet out there
maybe there's something interacting with it gravitationally and so they did the
calculations they found out where the planet should be and they pointed their
telescopes in the sky at that location
the planet they found we call Neptune today
now this was awesome to be able to do this and there were still discrepancies
in your illnesses orbit so they did calculations they said maybe there's
another planet out there
Planet X they did the calculations they figured out where that point it should
be and they point their telescopes into the sky at that point and they looked
and they found nothing
and this was a problem and they said okay but they continue to look and
eventually they saw something and it wasn't where they expected and it wasn't
really the size they expected but they said we found something and it's a
planet and we're going to call that thing
pluta fast-forward 60 years astronomers continue looking continued taking
observations and another one popped up
same size same composition
same location and then another one and another one and another one and another
one
an astronomer said that oh this is not looking so much like the other planets
this is looking like the asteroid belt a collection of objects that all share the
same orbit but aren't really planets not what we think of as planets and as the
evidence as the observations continue to build a stronger is ended up having to
abandon this explanation of Pluto is being a planet
it didn't fit in the same way we need to abandon the scientific model
it doesn't fit instead embrace the cycle of scientific thinking
you don't have to be an expert to do science
you don't have to know everything to answer your kids questions about science
even if the answer is I don't know what do you think
observe explain predict
that's enough it's good enough together as parents as educators and as
scientists we can prepare our kids our students our schools and our country for
the challenges of the 21st century and beyond
if we can learn to think differently about science
over time thank you very much


Debugging with the Scientific Method - Stuart Halloway

alright testing two different mics here we are good
alright so I guess I should make a couple of clarifications on the
introduction before we began I'm pretty sure that Alex just to attain of
causality whereby I can say that I'm responsible for strangely so I'm pretty
excited to have discovered that and can't wait to see my checks in the mail
the second thing that he implied a little bit was that there's a lot of
opportunity to watch debugging happening on the product team if you work at
convaTec in actually you know to Tomic is really no bugs at all so I don't know
I don't know what he's talking about their either but seriously you know in a
closure audience I really want to begin this talk with a rationale this is
something that rich has instilled as a value in this community and so I put a
lot of effort in having a good rationale or trying to and i dont have actually a
multi-part rationale for this talk of the first one is debugging why should we
care about debugging and I think there are there's an obvious reason because
bugs right we have bugs that is a you know there's some estimates that that
have it that 50% or more of the cost of software development is actually
tracking down the bugs later some of us you know working environments where we
get to run away and somebody else has to do that so depending on what you do you
might not always feel that but if you own something for awhile you come to
realize that that's pretty obvious the second thing is that the body is is
really quite straightforward activity and so you know Alex made some sort of
some sort of positive adjectives to describe my amazing awesomeness at this
or whatever it was that he said and the fact is this is not hard to do but
people think it's hard to do and so you can look disproportionately smart by
doing it and I am continually intimidated by intellect and the
achievements of the people in this room
every time I talk to somebody and they have some new area of knowledge that I
didn't even know existed about which they are expert and so to be able to
have something where without the expenditure of neurons you can appear to
be very bright is is a valuable thing to have in the final thing in this is quite
subtle and I will call this out this much in the talk I mean it's really
probably probably have about eight hours worth of material corked up right now
but there's a there's a a follow-on strand which might lead to an
interesting conversation which is that understanding the way that I and by
proxy rich think about debugging might help you understand some of the
aesthetic that goes into the design of closure and the process in the evolution
of Crow closure has come to my attention that sometimes people out in the world
have more than one opinion about how to do things in the closure community more
than one opinion about how to do the Getting Started experience more than one
opinion about how to do documentation more than one opinion about how to
handle exceptions we have lots of different ways of doing these things and
I'm not going to lay out a here's one way to do it
rights fantastic that there are multiple different ways but I think that the
scientific approach to debugging we knew it when you adopt it
it influences what kinds of tools and practices you're gonna reach for in
other areas and so that's very worthwhile of follow-on conversation
tonight those who continue on into office hours
office hours will be held at you know whatever local bars stay open the latest
second thing as a rationale for why have we talked about this a couple of reasons
I'm a closure screener I am also an enclosure has a process which is not
identical to every other get her project out there as you may have noticed and so
I in fact push all of the commits and have for many releases now I read every
line of code that goes I read every line of code to closure since the 10 release
and subsea know a lot of things I've seen many more things didn't go into
closure for various reasons and i've seen
things that were bugs and things that were thought to be bugs and not books I
also typically AM the the place of last resort and atomic support that doesn't
mean that you're on fire if you calling you actually I entered into the phone
right we're just rotating around but but I'm often the backstop on the heart
problems and so that is giving me an opportunity to own the system for a long
period of time and to observe bugs that we've had and bugs and other people have
found that we had and bugs in their own systems that we've ended up helping them
out with because of the support relationship also I'm gonna make a
little bit of appeal to authority here iron this gray hair I've been doing this
for a long time and and my hair was not great at all when I first started
debugging so
I'm pretty sure that the most of this is directly related somehow the alternate
theories that has something to do with children and finally I am really lazy
and not the most terribly lazy person in the world because you have to be
competitive right to be that lazy but I really
I really don't want to work hard and so I want to have an approach to solving
problems that allows me on most days to close up my laptop at five o'clock and
spend time with my children and have a tasty dinner and a glass of wine
whatever watch whatever HBO's most violent show and are currently is on TV
go to bed so I'm lazy and you can benefit from you know programmers were
all about laziness we're all about finding tricks that will let us do
things easier ways and so I think these all contribute then the question is ok
we talked about why debugging and why a maybe I should talk about it why should
we talk about the closure context will Karen Meyer my co-workers pointed me at
this thread on Reddit I believe in the text of this doesn't really matter but
but you can read it as you know Bloody Bloody Bloody Bloody blackberry messages
Bloody Bloody Bloody Bloody blob and it's basically the sort of beginner
experience of closure a lot of people when they are new to closure
particularly struggle with debugging the product problems figuring out what's
wrong when something doesn't work and so this long thread on Reddit where people
talk about the problem of this was actually the the post that launches it
and get it sorted captures you know some of the tone and a lot of times people do
things like well had a problem and i got a cryptic error message or I was
interacting with a dependency or lining in plugin or something I didn't
understand even where to start looking for my problem or I had a air quotes
type air in my system that we haven't really found if I was working in Java
and I now feel flummoxed and so there are a lot of people whose experience of
debugging closure is is fraught unpleasant in my experience has not been
like that and I'm not saying that there's they are wrong and I'm right but
I'm saying that you know
I might have some ideas that could make it pleasant for others and so that's
kind of an objective here now before I go further
how many people in here show of hands have helped to develop tooling and the
closure ecosystem worked on any kind of tool so lot of interesting tools in the
closed ecosystem there a lot of interesting tools about editing about
debugging about visualization of data about visualization of flow people got a
lot of different things and this talk is not about that and I want to make it
clear up front that this talk is not guarantee that I have a huge proponent
of using tools that being said if you do a Google search for the buggy and I did
this you know the vast majority of the hits are about tools my overwhelming
well more than half of the Google has all the resources out there are about
tools and so I don't think you'd be getting your sort of Kindle a keynote
value-add if I told you how to use tools cause there's a lot of good advice out
there and the thing is about tools and interesting tools is not directed by
tools right there is no TDD out there the stands for tool directed development
we will the tools they don't wield us and so when I think about debugging I
want to have a set of ideas in my head that give me direction or as that great
philosopher of Computer Science Yogi Berra said if you don't know where
you're going you might end up somewhere else
this is one of the biggest problems when people start to value system right one
for my for my spiritual support perspective you know what you discover
the first thing that happens and you start trying to help somebody with a bug
the first thing you find yourself wanting to do it like I really want to
go back in time to when you first thought there was something wrong before
you started doing anything I want to go back to that point where you started
acting before you had a plan before you knew where you want to go
you know it's so often the case that and I'm an advocate of being a self-starter
right so by all means try things but have a plan and then finally why would
we talk about the scientific method you know I had considered for a while that
the approach that I used to debugging was a scientific method but had not you
know read the literature on the scientific method you know past having
had a science degree in college and I had not read what people had to say
specifically about the scientific method so of course I turned to Google to find
out why should care about the scientific method and what I discovered is that the
scientific method apparently is because rainbows
which I have no idea why I'm pretty sure that all the sort of conveying the
Edward Tufte people out there are just no pulling their hair out what are these
colors even mean
and so rather than use one of the pre-built graphics with a meaningless
come colors have made my own scientific method for debugging graphic it's not
that different from any of these except got all the colors removed so because
it's also sort of the limit of my ability to manipulate the gravel so what
does debugging all about will debugging typically starts with the failure so
failure and by the way in contradiction all the terms i'm introducing I'm gonna
give you something from the etymology dictionary on them advice to future you
know
proposal submitters if you use two or three words that are slightly unfamiliar
and make reference to an apology and your abstract clearly clearly that's
something that that is valued in the space so it is a failure a failure as a
lack of success or better it's an omission of expected action expected
something and i got something else now as a result of this failure hypothesis
and hypothesis is an explanation that's made without complete evidence right
without necessarily enough evidence to answer the question actually maybe you
don't even know whether you have enough evidence to answer the question maybe
you do but you haven't sort of worked through the process enough and acts as a
starting point for further investigation then given that hypothesis you perform
an experiment which is a test on a trial and after that experiment you make some
observations when observation is active acquisition of information from a
primary source now in a good experiment 1 of 2
equally good things can happen you can discover that the observation falsified
your hypothesis so falsification is a deductive process using Pakistan as you
say I'm hypothesis implies there something I should not see there's some
observation of that I shouldn't see I run experiment I see oh well if I am I
miss my thinking has been rigorous and hypothesis as if this is true
than not I should happen ICO my hypothesis is now dead and that's great
I know it's disappointing if you're trying to get grant money in the kind of
regular everyday science but in debugging this is good news right we've
now I killed a possibility that's good
the other possibility is that the hypothesis is supported by the
experiment that maybe you still don't have an answer that sufficient to let
you say I've isolated at which point you need to do refinement and refinement is
removing impurities or unwanted elements right subtractive so I have some sort of
story here now my story may have to get bigger to remove elements are not
actually saying the number of words in your hypothesis is going to go up or
down but the conceptual size it is going to be focusing in on whatever the actual
problem is and then you know eventually and I'm not gonna promises happens after
two or five iterations but eventually you have a hypothesis and hypothesis is
something that offers I'm sorry theory is a hypothesis that offers
has been validated by predictions now this does not mean theory is guaranteed
to be true it does mean though that it is true given all of the information we
have so far right so this is another place where people go wrong and I see
this all the time
right you know I have ninety nine pieces of evidence in favor of this is where
the budget and I have one little piece of evidence that flat-out contradicts it
and I don't understand that piece of evidence and so on 99th pretty good I'm
just gonna keep going right if you have that one little piece of evidence that
says you're dead you're dead right you can't end and we get attached to our
theories get emotional about you like you know what I really like that theory
and look at 99 good pieces of evidence in favor of it can't do that now it
turns out and sort of I get dragged into the history of this you know researching
the you know what other people have said about this for the stock it turns out
that there are all sorts of objections to the notion that the scientific method
is how science actually gets done some objections are superficial
or idiotic perhaps but there are there are more serious concerns as well so one
of the things that I studied in graduate school is Thomas Kuhn's the Structure of
Scientific and sort of there's all kinds of pity ways I could unfairly summarize
this but it essentially says that that science is a little bit better than
politics or religion in that you wait for people whose ideas are gonna die out
to die instead of actively going and killing them right but it basically it
basically paints a pretty unpleasant picture that science is an extremely
social process right that how could it not be rites performed by people and
then once you have this notion that scientists a social process it's opened
up to what are the social priorities behind science and you get all these
moral challenges to science so these hot-button things you know they change
from decade to decade one of the hot ones when I was in academia was the bell
curve right this notion that we're going to use science in air quotes to sort of
split the human race up into different groups and say you know these groups are
are more intelligent in these groups are less intelligent that's not the case
certainly not justified by the evidence but these challenges are real and here's
the funny thing right here's the good news right there's all kinds of stuff
that I just said that we could have very heated debates about and get angry about
it in the context of debugging we don't have to worry about anything any of that
stuff it turns out that debugging if the scientific method is the measure of how
science is done
debugging is actually more like science than signs
science is hard it's difficult to imagine how you can take that little
process I just have in turn a crank on the side of it and come out with a
theory of gravity for the theory of evolution right of any of the other most
important theories that people have ever funk but that's not what we're doing
right that is not what we're doing we're doing something that is far more
constrained right and debugging is deductive and inductive we're not trying
to come up with a grand theory of everything right we have a grand theory
of everything it's called the proper system we're running we're trying to use
that to prove some very concrete thing right this thing happen also there's not
a big political problem right there is not usually I mean in my experience
debugging in and of itself has not been politically fraught right there are
people who are experiencing bugs and they want to see them fixed and as the
developers we want to see them fix so we're not having these kinds of
arguments and there's not generally a lot of moral outrage right and there's
not any kind of like academic left saying you know there is no real reality
so you can't actually you know you can actually prove that there was a book
here right there's there's none of that so I mean seriously this is really good
news so so unfortunately the scientific method may not be all that great for
science but absolutely rocks for debugging now having said that we can
drill in a little bit and we can start to use some more specific terms that are
more about troubleshooting and debugging gonna replace the word hypothesis with
cause we're looking for a cause and the definition of a cause is an event
proceeding in effect without wish that effect would not have occurred that
sounds awesome right if I knew the cause of the problem then you know I could
eliminate the effect of not being so I caused strangely right as we said
earlier so you know so the problem with causes that are not sufficient right
cause the universe exists right if the universe didn't exist this would happen
that's a cause but not very interesting 'cause and it's not one that software
we're not in a position to do anything about so you wanna get from a cause to
an actual cause actual cause is the difference between the actual world
and the closest possible world in which the effect is not occur and week I mean
we could go down the rattle of getting regrets about closeness I'm not gonna do
that in the stock but we can be intuitive about closeness right if you
have you know the glamorization of five things that all contribute and with four
of them it doesn't happen and one of them it does then that one is closer to
being actual cause that's what the paring down process does we want to
start with an idea about a cause and we want to narrow down to an actual cause
and then great word in this context a fix is just the last experiment right
the first experiment is reproducing the bug and then there are a bunch of
experiments that are about hypotheses and a fix is the last experiment this
captures a really important idea which is if you have it fixed it and run an
experiment that shows its fixed you haven't really identified the bug get
you may be strongly suspicious that you've identified the bug but you
haven't actually identify the body to you fixed so I'm gonna take this
scientific method and I'm going to apply it really slapdash way to problem and
I'm gonna start I'm gonna start with a problem that I grabbed off the stack
overflow this is a very tiny debugging problem you can probably do it in your
heads so sure to use a question on Stack Overflow why is this partial not working
so I defined partial join as the partial of closure strings like join with comma
then I called partial joined on fubar and I get back the scary error message
class cast exception cannot cast job cuts bring to closure lined up I fun and
it's a scary number in it so there's no way we can possibly figure out what the
problem is with this terrible error message
so what do we do when we have a lot of choices here we can make error messages
better right we could have an error messages since I see you were trying to
make a partial withstood join and you know that has this exact scenario we can
anticipate every possible scenario anybody could ever gonna do and not to
be unfair as we could go a long way toward having better error message was
not being error messages can be made better sound like a good plan to meet
you get a better docks into this problem the documentation we could use a
debugger intact in this case it might be even that syntax highlighting per in
highlighting would have tipped you off as to where the problem was I didn't
give you that may be static typing would've helped I'm typing would have
helped you can imagine a scenario where static typing will solve this problem
using some sort of schema schema validation would have helped and in fact
this one so easy that you might have stared at it and just know what the
problem was so all of those things are useful and all of those things should be
part of your talking except for maybe staring at it like that was actually
really quite we can come back to that but the important thing to realize here
is that science is more general purpose and requires less on hand to do than any
of these other things
say that again because it's so important but scientists more general the
scientific method here not science the scientific method where we can even be
academics a hypothetical did activism
let's just stick with scientific method the scientific method
is better sauce then these other things because it's more general because it
doesn't require anything to exist in the world except your brain so let's try
that when you go down this road and I said in a release slapdash way my
hypothesis is going to be will look there's only three things here why is
this partial not working well join doesn't do what I expected to the very
fuzzy hypothesis were partial doesn't do what I expected or death doesn't do what
I expected right that's it has to be one of those three things those are the only
three things they are two very small problem to to check and so the
experimental approach to this I will propose a heuristic for small problems
like this which is you should do a bottom-up check from the rubble right
pick the form at the bottom
that's on the inside and check that in this case we're done right I checked the
very bottom form here the bottom line was closed strings like to join comma
which returns comma that seems like almost certainly wrong because if it was
just going to return com I could have just passed in common to begin with and
then when I look at the next one partial join if we if we substitute in the
result of that right in the next in the original form we're now partially
overcome which is using common as a function so by applying the snow I got
lucky this time I might have had to do three little things that the report to
figure this out and I got lucky and I only had to do one so weak science is
stronger than strong tools in this case at a poor problem statement I really
never got clarity on my problem statement I had really poor hypothesis
which one of my hypothesis was that was out that was out there that was out but
those are not very specific experiments didn't even really have stated goals
right I just sort of took this heuristic approach I didn't have much to my
knowledge right
hypothesize that
beginning closure programme doing this didn't have to have much to me knowledge
to figure it out so of course at this point I have stacked the deck in favor
of the scientific method by picking a trivial problem if you promise matter
what you do
anyone who approaches work so hardly matters so now we need to talk about
heart problems and what it would be like to the scientific method well so what do
we need we need to do it steps way better than we just did you clear
problem statements we need efficient hypotheses we need good experiments
useful observations we need to write things down I'll start with problem
statements right the antithesis of a good problem statement it didn't work
right it didn't work is hiding everything behind pronouns let's not get
it right what you want the steps you took what you expected and what actually
happened just like right there that's 100 bucks
checks but this is not a hard thing to do this is not harder then and in fact
sometimes saying it's actually caused you to realize what the problem was
going from the exercise of verbalizing it didn't work from the exercise of
verbalizing you know I stepped away the car and started to old I didn't put it
whatever so so problem statements you know there's a lot as I said I V hours
of material there's a lot we could say about problems with this is all you're
gonna get right now but this is an order of magnitude better than it didn't work
so start with this the next thing you want to do is to
so I want
and I tell you
I mean it's it's Casey Affleck but it's the Malloy twins oceans 11 and there's
this great scene where they're playing 20 questions and he they're playing 20
questions and he's like am i alive yes my person yes Evel Knievel
and and it's a joke on an idea that we all know it's like the opposite of what
you want to do it so that's what my five-year-old does we're playing 20
questions he's like ok we're gonna play 20 questions he looks at me those are
you might oak tree
we all know we all know what we need to do here we're forming hypotheses are you
want to form a hypothesis that ideally carves the world in half and so it turns
out that the naming around this is contested right most of the time you
hear people say this is divide and conquer but if you ask a an algorithm
for something that's actually not it because in divide and conquer you go
down both branches and so they want to call it decreasing conquer which i think
kind of sucks because because it doesn't count me in decreasing conquer could be
a linear-time thing right
decreased by one every time and the important characteristic here is
proportional reduction right I want to take the space of where the problem is
and I want to reduce it by ideally half but as you know if you done any
algorithm analysis right if I can get rid of 10% of the possibilities on every
step I'm gonna have the answer really quickly but that's only going to differ
from getting rid of half the possibilities by constant factor the
number steps that have to do so the question is then how do you take the
space of i don't know what was wrong and turn it into you know something that
cuts the world in half
well this is going to require to my knowledge there's no two ways about it
having said that it does imply that you should be super cautious on your initial
step if you don't have much to me know if you don't have much to me know if
it's possible that your initial step leaves out of the entire universe of
possibilities what the actual problem was and so having said that everybody
knows where to look for their bugs like if I showed your application stack it
something just stopped working but how many of you guys are gonna guess
how often I just isn't right how often is it physics its
it's pretty rare I sometimes it is and that's exciting and I have to say that
on every open source project I've ever worked on you know you get bug reports
and some of them are bugs and you fix them and some of them are not bugs and
some of them of drugs into something underneath you right we've never had a
closure bug report that we had to forward on the physics right haven't
been any of those very few even have to do with you know GBM much less OS
operation and you can make other stocks like this there's a there's a whole
conversation we could have about sort of developing a notion of what the possible
spaces and you know where you're going to but my point is you don't have to be
that good at it anyway as long as you can get rid of some proportion of the
possible causes with your experiment you're gonna quickly find the answer now
what is a good experiment a good experiments reproducible
you start by reproducing the bug it's driven by a hypothesis people say
they're experimenting with they're just trying shit right that's not hypothesis
you have an idea this is the case and then you have an experiment that
provides more information to help you find that idea also experiments are
small and when you are when you're making changes to the system change one
thing at a time because if you change two things that you have to go back to
figure out what the impact that was when something changes are you know you
haven't actually gained information so I give you a quiz on this if you have a
bunk let's say you want to report a bug in your own app and you know you're
heading off to another member of your team to help you look at it which of the
following things should not be in your report ace your test cursive prismatic
schema mage potemkin in trouble lining in line with plugins court type test
general unless you're actually unless you think the bug in one of these things
with one of these it really stands out as well you really wouldn't have that
report case and the answer is it's a trick question you don't want any of
these in your case unless your theory is that you know the shopping cart on my
system
doesn't work when I'm developing inside cursive and using closure . test the new
repro k shouldn't have anything to say about cursive enclosure . test and Colin
notable will thank you for that
about that kind of thing either so it's incredibly important to remove things
that do not contribute to your hypothesis statement and it's a freebie
when I was saying earlier that you have to have this like mental model of the
universe to allow you to narrow down the things that aren't it right this is a
freebie right in your bug these things are not it so start by taking about make
a really tiny thing that shows the problem now when you're making
observations what's that all about one thing you need to do is you understand
all the outputs of your system as outputs
45 outputs that you understand and then as one that's unrelated to your current
problem and you don't understand it breaks screech you don't understand how
do you know the trade your problem not so you'd understand the OutputStream
system and you need to be suspicious of correlations where's the code in the
last the bugs in the last five lines of code you wrote quite often and so if
anything correlates with the proper the failure appearing when you wanna suspect
that in order to make up good tools you need debuggers you need logging metrics
all the kinds of things that lets you they basically all those things give you
more outlets I think turn things that are black box into things that are white
box and it's amazing that we have this inversion that when you do a Google
search for debugging more than fifty percent of it is about just this once I
believe when some point it's important right you need to have tools and in fact
there are more things tools can do just sit and talk about those later so I'll
give you another example in and while I was writing a stalker had several things
that happened to me in the course of the week so this is what happened last week
was working on
closure AB and I got this error message in the log was completely unrelated to
my problem right my problem had nothing to log back is the configuration file
for log back which is one of the Java logging things which were also happy
that job did such a good job with and get this message and i'm having this
cryptic problem in a subsystem that I'm working on and I know this can't be yet
cuz it's just has to do with logging said that actually this was it turns out
that after you know two minutes looking the problem said you know it before I
think about this problem and go run down what this log back things about cuz I
want this to be clean well log back across multiple times on the classpath
because some library because of a build problem had been copied into a lib
directory twice at two different version points so I had food at bar version 2.1
and food at bar version 2.2 now with the JVM helpfully doesn't it without further
configuration is if those things have overlapping but not entirely union set
of named things and you can get some of them from one end to the other and
they're not compatible with each other and it can lead to all manner of areas
that are absolutely cryptic which is exactly what happened but by tracking
this down I was able to you know what I saved myself all that time and it would
have been even using the scientific method and trying to sort of by six
towards a problem it would have taken a while from the symptom to come up with a
better cause to investigate the one that was standing in front of my face
write things down this is the single most important piece of advice I'm gonna
give the stock write things down right the problem statement down don't say it
right down right you're right every hypothesis down right what the
experiment which show right why did spirit makes sense right a justification
for the experiment before you run it and write down your observations and this is
something that we all know intuitively consider the game mastermind so in the
game master mind that the colored pegs down at the bottom
represent a code that the players trying to guess and the colored pegs across the
top
represent past guesses and then the red little red and white pegs represent
information feedback that you've gotten your past guesses so if you view this as
a scientific method right you have a series of hypotheses about what the
colors are and you're getting feedback from an experiment which is the human
player is scoring your guesses we don't have to talk about the exact scoring if
you can't remember how mastermind works that doesn't matter the thing that's
dominate here is that doing your experience with right without letting
things down is like paint playing mastermind like this you're saying that
you're gonna keep in your head the entire state space of all the previous
things you've tried and even the one try you're currently on your gonna hold in
your head so she can barely see one of those through my career and the thing is
that not writing it down right you might think that of the seven deadly sins that
slot but actually not humorous it's amazingly arrogant not to write things
down basically what you're saying is I'm such a bad assets solving problems that
i'm gonna solve the problem of keeping track of everything in my head just to
show off when that's actually probably harder problem in the debugging the
people do this all the time
staggering ok everything I've said so far probably could more or less apply to
the use of scientific method in a lot of different domains and because we are
here at a software closure conference and maybe some software specific advice
and the first piece of software specific advice
is something I was reminded of as I was reading through the literature on
debugging and what programs are said about the bug in the past and I usually
don't say mean things like this is gonna come up I mean I can't help it
don't you see the history of debugging is just riddled with all my god this
thing has so many pitfalls and traps in it and it's not that C is bad you have a
separate conversation about it is that this is not a level of abstraction you
need to be working it i mean and sometimes it is right and if you have a
domain that like it would be impossible to do this in Java foreclosure or what
Python whatever then you can you see before you shouldn't reach for that as
the default or and 2015 in most Americans second piece of software
specific advice
the failure is not the defect the failure is not the defect in the way
this comes up the most often in software is assuming that the exception has
anything to do with the actual problem and it does have something to do with it
that's how you know right but that it's in some way directly translatable into
the problem so give you an example
system that had a large very high CPU utilization and then
IllegalStateException Hornick you so your first guest is no exception you
must be broken
well let me just tell you when accused not broken when he was a pretty awesome
piece of software I've had fantastic interactions determine his head from the
zero point zero days I've had fantastic interactions with the morning you team
and the only time that working with those people that we never got to the
point where we track the bug down to the point where it was underneath atomic in
Wanaque it actually was underneath 21 St which is pretty unusual by the way don't
find those those Camino Real this is a show-stopping ninety-plus SSL doesn't
work in the scenario bug so pretty darn unusual so this was not this bug and
I'll just tell you and give you a little bit unfair means information the answer
was not its wernicke you and there's another important philosopher
of debugging who can really help us out here in a couple of steps and that his
house so how says it's never lupus well in closure programming on the GVM we
have a kind of anti lupus right we have the thing that it always is but it
doesn't look like it at first and that thing that it always is garbage
collection right the actual book is always garbage collection just as I just
isn't house it's never lupus enclosure in Java it's always garbage collection
and there are several reasons for that one is most applications are not
designed to deliberately induced go out of memory errors because they're not
designed to deliberately induced those those compassionate check very much so
you're in kind of uncharted territory the second one is out of memory can
happen anywhere so there's no line of code where you can go look there's the
critical section where memory doesn't possibly run out and you can't do that
also an American appears almost any other exception because one something
failed to allocate over here you can get a cascading series of reactions when the
actual exceptions reported back is radically different finally finally
finally when you get close to have memory you get a radical change in
thread scheduling as the GCC threat is running all the time and all of the
sudden things are happening in orders that they never happened in everyday
life and so all those race conditions that would normally take your system two
thousand years to expose the accident all the sudden it takes them two
thousand seconds to expose by accident so lucky you thanks garbage collection
for helping us find those conditions and finally out of memory related problems
tend to cascade so always be suspicious of memory when you're having problems in
a garbage collected environment now another piece of software specific
advice is to read the entire fracking manual
and so the thing is that a book almost by definition starts out as an unknown
unknown
a few more about it you'd already well on the way to fix it you don't know
what's wrong
so you don't know which part of the manual you need to read and this means
that if you want to set of docs that are good for debuggers that set of docs
ideally is short and specification like now this goes against other objectives
right short docs may be very difficult to consume they may not be very
narrative they may not be very tutorial but they are a good place to say you
know what I have to read the whole thing I would like for it to be fifty pages
long and not repeat itself if I want to learn in a more neutral kind of
environment I'd like her to be a thousand pages long and repeat itself in
various ways and anticipate problems that people have every day so good docs
for debuggers are specs and we'll go back to the partial problem again so if
instead of doing experiments we had chosen to read the docs here we could
put up the doc string for join and we've seen that join us to air at ease and the
first guarantee takes a collection and then it returns a string of all the
elements in that collection so one step + experiment would identify this problem
one step + reading the docs would identify this problem would be the first
thing you found when you want to look for it so let's take some of these ideas
back to this more tricky debugging problem that we encountered and that is
this large nato mccreary high CPU utilization illegal state takes action
now to give you one more really piece of interesting information it happens on
Cassandra in production but not on each to and development so what should we do
right now if we're going to apply the method what we need to do right now is
look very suspiciously at that last sentence is that less intense an
observation hypothesis what is actually not really anything but it doesn't have
a subject I sent it without the subject in it so there's some sort of amorphous
it that happens on Cassandra and not on h2 so let's try to define that it a
little
get that certainly sounds suspicious so let's make the smallest possible thing
that could show us that so we'll create a test environment with the same day
that production had and then we will run a little file that we're gonna write
which is gonna be 10 or 15 lines long test on job with atomic pier and that's
just gonna come up and it's gonna perform the problem query in a loop and
if Cassandra word atomic or Cassandra + tectonic is truly broken in some way
we're gonna see that there and then we can run the same test again against
death and not see that there and now we have eliminated an entire universe of
complexity right all of the application code that was in play all the tools of
the third party dependencies all that other stuff has been mechanically
eliminated well so we did this and what did we learn the problem happens on
Cassandra that's this is our statement happens again later but not on each to
do we create the tribune repro and happens with Cassandra and guess what
its limits so it turns out that this query was just using more memory than
the JVM hadn't had no chance of winning and so that's that's pretty suspicious
because it's not at all obvious why Cassandra would be such a memory hog and
use a time or two that seems really you know their driver you know be messed up
like that well you know stop hypothesizing let's go test h2 the
definite storage and guess what the trigger Reaper happens there as well and
that leads me to the other important observation that we get from house which
is everybody lies right it turns out that it was not the case that the
Cassandra and h2 behavior were different it turns out that there was a
miscommunication about what had been tried and so by the way never attribute
to malice what you can contribute to accident on this communication this is
not lying in the sense of covering up her drug use which is always when it is
on house rate this is
this is this is lying as in saying a statement which turns out not to be true
I'm having trouble teaching my kids not only called outline any statements turns
out not to be true later turned out to be slightly mistaking you lied like
actually we tend to use that word employment so this is kind of like this
is the you know go back and double check statements and again going to the
exercise of reproducing it
imagine how much fun we would have had if instead of doing that we tell across
a conference table and atomic team at pointed at the Cassandra Cassandra
disappointed at any time of death and said you know you guys I messed up
somewhere cause this works in other contexts but we didn't even have a
problem don't we did that now the final piece of advice I give you a software
developers is that the body is fundamentally a search operation we
should ponder that a little bit because this is something we actually know how
to do right we actually know how to write algorithms it do it so instead of
limiting are thinking about debugging to the ability to see things or stop things
why don't we write programs that do this job that I just described
implement the scientific method in code make something that automatically
generate hypotheses and then automatically runs an experiment and
some of you may have done that in a small way using get by set by sex is
actually partial automation of the scientific method right you write a
little program it's gonna test for something and then get will bounce back
and forth cutting off the cutting the world in half every time until it finds
the boundary with your test changes that's automating the experiment part as
end and we have you know we have a set of possible worlds states already given
to us from get well this idea is well suited to be taken further in so many
gave you your first maybe closer con call to action this year which is going
read this book Why programs fail by Andreea seller and in particular there's
a lot of ideas in this book that have now become standard practice of their
chapters you can skip but in particular read Chapters five to seven chapters 11
through 14 which actually layout algorithms for doing automatic debugging
of programs and so what they're doing is modeling the entire state space of a
broken program and the entire state space of similar programs that
exhibit the failure and then shrinking the difference in those states basis do
we know how to do shrinking in the closer role we're pretty good at that
right we have test out check and test their algorithms for this so I would
love to see maybe a closure Western media classic lines next year
somebody giving a talk about taking the ideas in this book and realizing them
enclosure mostly ideas in the book are demonstrated with Python code and I
don't think we should not let them have all the fun right
this is a problem which is well suited for closure as you might imagine one of
the places where things get complicated as I can just glibly say the entire
state space of succeeding application and the entire state space of a feeling
that we can but how you actually capture that well that's a hard problem but it's
easier in a language it doesn't have very much to write so to the extent that
it's possible at all right in a polyamide Python program it ought to be
a lot easier to do in the closure programme you know by the way having a
language that you know models code as data and pat is everything around it we
are uniquely in a good position to implement these kinds of algorithms so
that's the Sun that's the software specifics work at a high level of
Attraction remember the fault is not the defect remember that Dec did it read the
manual twice don't trust people I reproduce and let's go out and automate
some things and you know I've been told the six bullets is too many to remember
it in a long day so make that even simpler and say listen back up and talk
about science a little bit really easy know where you're going right
remember you if you have if you're heading into particular direction have a
much better chance of getting there and then make well-founded choices this is
where developers both beginner and expert make the most frequent mistakes
they're under pressure and something's not working and you say and we've all
done it and you say you know what I'm gonna try this stop and ask yourself why
should I try that stopped and asked if she could have to talk to another person
you can say pushing through I had this idea about what's going wrong and why my
keynote presentation didn't do what it's supposed to do during the middle of talk
maybe you and I can sit down after Adam talk you through me give you a
hypothesis the effort of doing that and writing it down
that's the final thing once you've decided you're gonna take any kind of
action justified that in writing first these those two steps making good
choices and writing steps down
are gonna turn a haphazard random walk around the problem into a directed
focused cruise to an easy solution and an early night relaxing at the bar with
your friends
thank you very much