Tuesday, October 04, 2016

Scotland on Rails conference 2009 - The Ruby Object Model by Dave Thomas

of this morning what I want to do
is to talk about something which Republican come away and saying why do
people talking about that
it was so obvious you know arm
but the smallest things that at least to me what obvious for a long long time
wanna talk about is how
Ruby does objects and
the resort talk about that is I'm now talked about Ruby for
on another eight years and the WAM confusion I always see
is when people start doing that a programming and they start looking
always
various called how does this work has just like this no
and this clearly no Wong mental model that people have about what's going on
underneath the covers how does Ruby actually do this
and that's what I want to talk about because I hope the end of this
you have a lot clearer understanding of how will be
does ok building is that
arm this is not just be spouting I would really love with people so like
you know say hey Dave how about this or that's rubbish
about this instead right so let's let's make this interactive if we can
amenable to see you the lights are gonna Breitbart
you know process now I'll find you so let's start off by talking about
why we care about objects where two objects come from
right why are they important a pop quiz who are these two gentlemen
sorry
this man
is Christian I got this man is only on DOL
I apologize want Norway what did they invent
Simula
thank you shame on the restive you because this is your history this is
your heritage
but in the early sixties these two gentlemen were asked by the Norwegian
government
to do simulations all enable naval shipyards naval
boats any particular things like how they were resupplied in redox because
it's really important to trial optimize the process upbringing a ship in
giving it all provisions and then sending it back out again at the time
they were working with procedural programming languages like just like
alcohol
fortran COBOL and
they started coding away I guess in alcohol
and they were rapidly ran into a big problem because
they discovered that they were dealing with all these things that had behaviors
trucks ships warehouses
but they also had all this data associated with them
what's in the truck how big the whole ship is
you know what's in the warehouse always kinda stuff discovered
keeping track of all the data Associated
with all these things these behaviors was really really hard in a procedural
language
so hard but they couldn't actually write this simulation
but being very clever people
having a spare five years they decided
up that the best way of solving this
was to write their own programming language and then printed
similar similar was written as a simulation language
but in order to be able to write the simulations
they also invented the entire concept
object orientation because they invented the idea
up capsulatus set updater and behaviors
his a truck it can drive you can load and unload
and it has the following state has this in the back it has so much
petrol whatever it might be think or object orientation
they invented if you have not looked similar
it's well worth it it's what is it now
forty-something years old and it's still
has concepts and that that we have not yet adopted
in current programming languages there are some very
very cool concept similar so similar kinda like bold along for a bit
and during the early seventies lol interesting but whatever I'll
then to other people got involved
is this
slightly more obscure anyone
Alan K indeed this man is Alan K
this is a man called more between them
did small talk unless
Alan K in Smalltalk took the idea is a similar
and made them the core feature of his language
and Alan K actually invented the term
object or into when he create a small
and again small talk is a 30-year-old language at least
and small talk has these features that most
model one just including Ruby to some extent
does not have smokers remarkably your object-oriented language
again if you have not yet plane
small talk and your roomie programmer you over to your cell
to go and have a play downloads week whatever it might be
and play with it also if you're interested in writing
I'll good code you put yourself
to get can textbook my brain just died
Jim can't local
all talk desperate as patents thank you small talk best practice patterns
right it's written for small talk it applies equal to Ruby
a really great book on how to respect your coat keep it clean
so Alan K invents a small talk invented the term
object-oriented he was live an incredibly
disappointed like
I invented the term of Georgia not
have C pas plus in mind
I wonder why that is
show that slide quite often to I am
symposiums Java programmers and the although haha look at C pas plus it's
not like the language
I put that up
see the point is
that what's become
object-oriented programming is not the way it was conceived object orientation
was block programming
with classes think about it
if you have someone in your office who is
unfortunate enough to like UML right and you tell a pay-go design the system
what diagram to use what's the favor Tiger
use last Agra design using classes
which is insane only good diagram in your military activity diagram or as we
used to call
Petrina that's a really useful blog and pasta Graham
democrat a programmer sits down to write
Georgia program and out program nowadays what the first also very first word they
talk
we no longer do
object orange development at least
we don't in the more conventional languages c plus plus
shop job instead what we're doing
is class order to develop and if all you do is class orange
development then two things for civil
you or not using Ruby and certainly
you're probably not this on your programs right because it probably means
you'll be doing things like inheritance
an inheritance is the work of the devil
you should not be using it ninety-nine percent the time because
inheritance leads the coupling and all the other since the fall
the nice thing is though Ruby
is an object-oriented language a true
object-oriented language if you're in the arm
charity tutorial on Thursday guess what you so that chatter Marcel
developed a program actually had
what looked like inherited and I wasn't class
insight that's because
Ruby is truly object on language and so
I think it really is important that everybody understands how to do
objects really so when I first came to ruby was
actually ten years ago and
I really got into I felt totally in love with it and I spent a long time
trying to understand how objects work a long time
I mean probably four or five years
trying to get some kind of model in my head
of what was actually going on when Ruby
was doing its object its current harassing it took that long
arm Mike Riley to get it
it was just so blindingly obvious
so utiful that is fueling your share
now wall things the I did was I went through read the source code
truck what up what was going on will be actually do this
an is helpful in a way
sorry in that
if you look at the source code you can see that worried us
objects is it emulates this idea that object
is state behavior if you look at the implementation of the single
our object you will do fine state the behavior
in Ruby we call the state instance variables
now every object
has instance variables associated with it that's where we state
and the behavior is by large
methods we also have props as well
by large the behavior associated with an object is a set of methods
it's pretty obvious you can see that really easily is pretty natural to think
that way
let me go to get deeper into it you come across
diagrams like this this is actually a diagram
in a so far object see in the resource Co
and it describes the
classes another classes that make up Ruby attempts
to make clear Howard use
that plus I'm sorry
everything is object object is a plus class itself
is an object does not make it clear
it doesn't
it's a very orkut diagram to look at because it has always wear terms yes you
read the comment that goes along with it
it talks about meta classes and met object protocols
always comes to it makes it very very hard
to see so let's try into this
a different way Astron cut back to the
the underlying basis let's start
by looking at a really simple variable in Ruby
there's a predefined read only variable
call cell all know about it
if your Java programming this it's the current object
it's the object which is I'll look top
whenever you go into an instance variable so if you take at Fred
it goes tries to find the instance variable Fred in
cell because reversal is an object objects
where we store state
we also yourself as the place where we going to look up methods
if you don't specify an explicit receiver
you say do something without him
I don't say X not do something to say do something
then ruby is gonna go and look for that do something method
in cell associated with object so
so self is phenomenally important
so fiscal like the thing that centers all Ruby code
and if you understand cell and if you can
workout what self is at any point in your running code
you basically understand Oristano
about mister programming
honestly you don't need anything more so
so the first thing to understand is
what sets cell how do you get soaked changed
because obviously the changes in Seoul is what changes
ruby's you the universe excusing
so understanding what changes so is absolutely critical as far as I can tell
there are only two things the change cell
shelf can change when you call a method
and sell changes need to find classes
and models as far as I'm aware
those are the only two times the self changes
so let's look at the first other to some light coating
ceramic all to myself the Huskies
so let's have a a variable
like variable okay so at this point the verbal animal
holds a reference to the string object
pack right nothing particularly exciting there
and I could say something like put s animal dot
up K and if I run that
I get cat is exciting
cool okay thank you very much I'll see you next year
notice by the way really want my long
runs perfect woman sex right now use Ruby 19 switch to it
art so those are capital a cap
I'll object and what's happening here
is that are invoking the method okay
on animal the Roosters okay
I'm gonna have to go to find up case method
in the object Associated with that cat
string and indeed that's exactly what it does
let's go have a look what's actually happening behind the scenes here
there's our animal variable and its referencing
some object some globe thing here
object prostate behavior so the state or object
is the string value Pat right it's a sequence of characters
CAT at this point we're no longer talking about Ruby objects were talking
about actual characters at this point CAT
we said objects also have behavior and the Ruby the behavior
said beth is now because all strings
share the same basic behavior
it would be stupid to put that behavior
in each individual string object so instead
what really does strips out and puts it into a separate bill table here
a table up the things that a string can do
and so we have basically a pointer from all
pack object table
methods and when Ruby
sees animal dot up case what it does is it goes
to our animal object goes one to the right
to find the table methods and then searches through that
until it finds the code up case on it finds that code
executes
pretty simple right now
because we have to go out live in the real world
have to reveal ugly secret what I call
table methods their is actually
class
but fundamentally all a class is in Ruby
is an object that contains a table methods
its object just like my animal object is
and as the way in the same way the analog holds the character Capt
string object holds the methods up case down case
stream trip whatever trim whatever it might be
so wanna talk about table methods I'm simply talking about object
the contains as part of its state a list methods
so here is the first secret understanding
Ruby metre per going already the object model
and that is every single
method call works exactly the same
way there are no special cases
in all cases when you invoke a method
on that object ruby goes want to the right
looks for the method alright
so what happens
if I did something like I wanna know
object ID run that means that
here I'm getting was it some magic number out
object ID how does that work
does not do much my my diagram here
their is no object ID method
string so clearly something else is taking place
and that's the next pop the equation
and that is when really goes want to the right
searching for the methods if it cannot find methods
in this particular object if
follows a little chain call parent
up to another object not a class object
in source code terms the subject is the Parent PLUS
the superclass this wall so if you say to string
what's your parent with the report object
no if you are back to record model and you said what is your parent it would
say
active recall calling on base
so the pair is simply the superclass
up the object so a method call now
is want to the right search
you don't find it co-op search
if you don't find it know all until you hit
top and the top in a review on 8 is object
re 19 its basic object
if you hit the top and you don't find nothing you're looking for
then go back down to the bottom
and not looking for a method called method missing
and fines method missing in the world chain
you executed and back object or
in Review Online basic object implement method missing
and that's what it is reports but no error
when you talk about nothing that's not built into the interpreter
what's doing is executing code define
object okay so that's how much the calls were coming but you all knew that
there's nothing exciting they're really
up let's play around a bit let's go back to our Alexopoulos
here
you probably know that you can do this you can define
in methods on individual objects
there's a lot of controversy on how you spell now
that's my way alright
so I can run that and
my animal all my cat do that
but if you take another cat can say that
only one object has that okay
so far so good but remember we said
I said asserted Ruby only calls object because methods
one-way it only ever call our method
by going once the right and an OPP so
somehow we have to make that speak method
available the sky
how we gonna do that
how do we make speak method available over here
the only way that can happen
the only way that can happen is if we have something
here have Speakman the fine right
on way to work so what was really do
ruby is a dancer
a brand new thing
here this is a plus
has that method that we define and it's it's
one to the right all are animal object it does not sit once the right
any other string it simply the class
all that animal object so we define that speak method
what we did was we created this thing here
we set the class pointer of our animal to be that
thing and then we set the parent all that thing we created
to the original class the animal so think about how that works
now if I say animal not speak what happens I'm here
no one to the right I find speak excellent just what I wanted
if I said animal dot case what's gonna happen
ago one to the right I don't find it here ago op
I find what they're so it works and certainly
animal 2.2 per animal object idea what everyone cool
is gonna keep going up the class Chancellor find so that is how ruby is
gonna implement
ability support methods on
individual objects the reason I have question marks here
is that this particular class is effectively
anonymous and not only
does it not have a name it's really really hard to see it
when Matt's designed Ruby
he decided make these little
classes effectively invisible if you said
to animal what is your class it will say
it's a string it lives
it's not a string it's one of those guys ruby is not gonna tell you that
show you a bit later on how you can get to that guy the other problem is
there is no I official
name for what this thing is some people call it the singleton class
because it's the class associated with a single object
and there's only one of them for object some people call it the middle class
some people call it I can plus
I started calling ghost class
because it's got an invisible just sits in the background
whatever it is sinks in class
I and class met a class they're all the same
idea its simply a little invisible class
will be creates for you to make certain things per
it'll make sense
Matt schools and different things he tends to use singleton
arm but if you're sure either source code he also calls and virtual
so I don't know I'd I mean
will be really nice we dislike came down a mountain and said
from now on you know
but yeah unfortunately not
sorry it would that's true
so that singleton class
as I say it's got lots of different names is
just like any other class except it has a little bit
Senate says don't reveal me to the outside world
whenever you create
methods on object so say for example
I create back here I've pretty much speaks method on animal
releases oh I need to create the singleton class
there's not one there to start with by t-fal animals just a string
such class point2 points to string but the first time I do this
it said okay now I need to create a single class
so it does that effect create new all
releases oh I forgot a singleton class
so put the run method in that singleton class
the New Year Wong singleton class
for object and it's created lisa Lee the first time you need
come
so that's the first part
afar equation the idea
that there's are two things that change
cell and 100 she know what
skip will be here when we talk a bit about how
how our method
gets call went down here say
animal dots speak reactions to go to find that speak
right it's really useful I find
to think about the mechanism as a kind a four-step process
the first thing is
that Ruby takes the receiver this guy here
animal and sets so to be that receiver
so before anything else happens
reset cell to be
that half object and that's why
right we've got on the diagram effectively that thing on the left
though the captured
that's where self is at that point Ruby
then looks for that method in
the method table associated with object classid
object so it set so then
scams insults class for the object it doesn't find it
than does the scam missing eventually will find some
cool you invoke that matter now it invokes that mess itself has already
been set
to the receiver to Pat so
as that method executes soap is going to be set
to that help and then finally
when that method exits returns Ruby restores the original value cell
pops a pack of stack if we can show that using
classes on the
so there since this method that sets
as this method it sets an instance variable
so I say new occurs on creating a new instance that plus
I say d top wall then
what's gonna happen South get set
to the instanceof Class D it searches
in the class for the method one if finds it so did folks that method
cell is set to that instance is a Class D
so it's it's the instance variable to miss his wall
it's being set this is verbal a is associated with a particular instance a
plus
the with an exit and so
is reset to what it was before we called the method so that if I
call to same thing happens
self get set 2d because looks for two methods it finds it
goes to look for instance variable called a and its associated with that
particular instance
for brings back the value Wong here in that movie is gonna say
wall if we change your program
and instead
just call to
here from than
the method called to has no receiver
if a method call has the receiver
than Ruby scripts two steps in the matter calling
arm chain it doesn't reset itself doesn't need to
soap stays the same the end it doesn't have to
pop back to previous value so so all it does
is the method lookup the method call so here
we sets of two bd find that matter the Wall
set ap a in that instance then we call to
we don't change so so simply look for the method to
in the Class D put this at a a reason for instance find
that puts it everything exactly has you expect that may seem like I'm laboring
the point but
whenever you get stuff better programming and you get
stop try to lookup how come that nil I
guarantee if you track value
cell you'll understand
where the sport has come from that's a really good question let's say
we always have a call yourself right self exists all the way
throughout Rico let's just that but
and I said that whenever you call
a method it's always been called on object Hills
how come that works well the reason that works
is that at the top level so has a value now
if you lost soul what is it says
I'm main but if you take a little bit deeper
and ask what's your class
it says it's an object so
at the top level a program is actually
a om instance object
with a couple weird little properties built in to make things work
okay when you're defining methods
in that the top-level you actually defining methods
I got minute officially in the sink in class object instance variables are in
object now where does put this come from
well protests is actually a
ago group right at the small
protest is actually a method
say one word for
curtain put this is actually a method all the kernel
about module and the kernel module
is actually linked into or included in class object so
any method this defined in model colonel
is actually I private matter the class object
so it's a protest just basically ghost
object and looks for put this matter in this method
find executes because everything is an object
protests could be used anywhere so I could for example
say forget really confusing
IRT it might be private I'm not too sure
we have a look
its private yes I couple in theory it's available every object because
its metal alright
so we've seen how so
changes on a method call the other place I set itself changes
is all a method definition class definition so let's have a play with
that
so let's define a class
yeah 10
now you know that in Ruby
class definitions are excludable code so I put one here
to their second output
123 pretty obvious the right because
the code up the class definition is executed or
it's just any code like any other with should be coverups cure to reprogram
you can do something like this now only has
13 it doesn't excuse the class definition right its
just code so
we said itself always has a value so self must have a value
inside a class definition let's have a look see the value is
and I put sell for the top
so inside and so
at the end fire on that
it says in the class definition self is set
today or what is day
let's go back and have a look I say
self-talk specter's a little
change in a long line not help alright what actually is the classic day
day
isn't object of class class this is where
English top
in London just like Java
or see shop whatever we need to find a class
it is a definition it's a declaration almost right we say
class something that something is somehow magical it's put into a symbol
table with classes
somewhere that's not true in Ruby in Ruby
classes are objects just like anything else so for example
here my day is simply a constant
thats referencing a class object so I can say you know
class again down here
the whole I'm just call a method on it yo
I could a sign it to a variable
I could say X equals day
and then I could say all
equals extort new nothing special about it
its just an object I can assign two variables and also its cool stuff
just runs so
when I define a class that class what's happening inside Ruby
is it creates a brand new class object and then
the signs that class object to a constant called a
inside the class definition self
is set to that class object
so far so good why this is set
so to the class object was warm
really really good reason let's say you want to find
what other languages call a class method no
well in Ruby you do that by saying
auto
there self-taught speak whatever it might be yeah
if I see all the school Ruby programmers
using that were all cool kids now use
this their equivalent because cell is set
to the object right so
if we do that then I can't book that object by saying they've got speak
this run okay so
most folks will say that defines a class method
those books all wrong was really doesn't have class methods
there is absolutely no difference between saying
their self-taught speak and saying their
animal not speak the identical
really doesn't even know that you're doing that inside a class
nothing special about it so what happens inside really when you do that
here is
our object model but remember I said
that that class misconstruing
our animal our class has a class of its own
yeah the classes string is plus plus
so if you ever invoke a method at the top level
on a string like that sorry on a clustering what
string not new or something like that what's gonna happen is your info key on
that string object
so the same rules apply you go want to the right the top
right so whenever you do a dot new a-class
it's a regular old method call on the class object
egos want to the right find new doesn't find it goes up
object released a report I we've already seen what happens
we define a method on a specific object
in this case we're going to find a method on our class object
my example typing their it was day 100 the fundamental on the class
so it is really do it inserts from local singles in things
exactly the same as on a Sat animal doll
so now if I said day thoughts P
it goes want to the right finds it well-executed
is that cool or what
right at a stroke
scored a metal object protocol
ass stroke the meta object particle Ruby
has eliminated an entire concept the programming language
there's no such thing as static method of class methods it doesn't need them
all methods are the same I think that is just gorgeous
it's really really really
you as a concept all you need to remember
in order to met a pretty roomy is that
this is very walls on the console and Methods
a look top insult class want to the right
and then aw remember that you know
Oristano a better program now I live in
in Dallas and acolytes is weird
transatlantic Sargasso Sea accent um
but we have a whole bunch infomercial on TV
in in States and invariably
it's obnoxious a welshman do them and
you know the cut the catch phrases but wait there's more and there is always
more
because
Ruby then goes on and gives you some convenient shortcuts for getting stuff
done
but the shortcuts on not necessary
there's no need for them in the language what you've seen so far
is good enough but we take it one step further
as well as being able to
define just method or object I could say at all
equals at know you see me before I typed
animal dots P or whatever that was
I that's one way of defining a method
on the object animal cat another way of doing that
is using this notation
right class less than less than animal
Iran that help actually called in
runs
so what happens when you say class less than less than
something the Western less than notation
basically means open-top
the singleton class this object stop putting methods
into that singleton class it's a kind of a shame
the arrows go that way if there is one
this way instead you be more obvious what you doing in the diagram
you're moving to the right yeah
your defining methods want to the right where you would normally define methods
and that's all it takes place when you say less than less than
if there's no singleton class for the subject recreates 1
and then just dump methods into that singleton class such as what diagram
here's our cap object
here is our singleton class or
wanna call it dictates pigment is a string object when you say
class less than less than animal it says if you have the ability to say
class and then whatever the name is this guy is yeah
all you're doing is opening up that box sick don't methods into it
yeah why would you want to do that
well on pets
on individual objects like that it's not so useful it can be occasions was not so
useful
I personally think def animal got something is clearer
think last less than most notably methods into it but
you may have seen people coding
a pic if you read the real source code they do this all over the place
you may have seen people doing this we should make DEP speak a macro
and
ownership and type thank you for telling me by the way
right see you may have seen people do this
and quite often they'll put the comment above it
to find some
plus methods
this is your
cargo cult thing ninety percent the people
could do that have no idea why it works they just know that if you put classless
the most myself
then ruby must be looking at that going cool he want
class methods up hope there's no special case
what so ever this is exactly the same as saying
class less and less than animal what are we doing
we're opening up the middle class singleton class dumping all methods into
that
so in the same way saying they've
does our death so not speak here puts that speak method
the same in class just approximately plus a foot speak method into it
now why do I say it's more useful in class is the
is with individual objects 10 things that I like to do
with class listen cell is to include stuff
at the class level that's normally done
at the object level put
people who are new to Ruby often make the mistake
some type so bad
delete move what code rings people who are new to Ruby
of a big mistake up defining their instance variables
in the same with you do in Java no job you'd say something like
you know static string whatever might be up
in your class definition what people think I have to do the same
in Ruby that's all the fun missus variable like this
and then they'll be really surprised
investors in Java right so we'll say
d equals they new
house AP ok for a
alright so do something like this not be really surprised
there's a bug in Ruby because I set my instance variable
but has not been accessed in the method but now you know why
yup because what's happening
is that
instance variables are always store relative soul
what's soulful here the class object
what's so former ex in this method it's an
instance the class it's a totally different object so there's absolutely
no
high in between this and this but
if we can have a method executes Wentzell
is set to the class object then we can get to the instance variable
so if I was to say self-taught get
fret their and here rather saying
day talk the deal get rid calling on the class
then that works right because
the class for both reasons we will set the same art the object is set to the
same thing
the reason I said that class lesson this itself is useful
here so I can do this
yeah so what I've done
after accessor only excuse on instances of
a shifting to the right I've made it now available at the class level
so now I can say they've taught
pretty cool wilma
with this Alfred
group up too late too late
yeah
that's pretty cool isn't it your heart crap
I think that's pretty cool
yeah everything you do at the class level
%uh the other uses little you can make your class the whole shifting across
Wall
so that's a useful thing to be able to do
and that's just an example
the other thing you can do it again this is just icing on the cake
you can inherit expression I
again in the church tutorial E the a muscle give an example doing that
when you say class Hussey class a
and last be
less than and
alright say look at that and every says oh yeah be subclasses
a right if we ignore the fact that subclasses the work of the devil
then you know you look at that you think okay that's intact
so what Ruby must be doing is here
that labor plus and that means subclasses
and that's lame a plus by the way the reason we use the symbol
subclassing look like two horns on the side so
you think Ruby must be looking at that and say nothing of the class
no it's not is really doesn't know about classes
real no idea about classes or does not object
member we said a is a constant
schools the I'll for subject so what ruby is actually looking at here
is not what they have a class is looking at an expression and expression happens
to return
a class object so if up here I said
weevil equals a now work perfectly fine
it's just an expression so I say
protest there as the parents
source a plus right
now that plus object string given a name
a which is why reports a but it's just an expression
that means you can do some fun things
I could do something like class
silly is a subclass all
if Rand is less than .5 a
array otherwise hash
that is why I called up typing so then I often say
PE silly new
saw a a superclass
run that code
ok it's alright sir shoes
i doing wrong
out is ideal just do this silly
new area alright
so that's how to create a hash ash again
array that time hash that time yeah
if you got callings that you really don't like
but there is
one really good use %uh this ruby has this really incredibly useful and much
underused thing called struck now what struck does
is it constructs classes so I can say
I say person a cost structure not new
name age
10 I so what that does
is actually on the fly construct a new
close object by saying right
it's a class and then I can create a new person
I could say day equals person
or new a and see I'm
27 alright
so just construct a new object that class but
the structure itself is simply a day to hold quite often you'd like to decorate
that with different methods to do cool things
arm and ask all look a bit tricky you could for example say something like def
person dot 2s
and they could have something like see
so name you
are and I said
protest if they're sir
10
up on the wrong thing I'm sorry yep
it you're right
okay I need to put that okay I put a spell on methadone
Dave just for now ago
I so I wanna put that method all the people like create
so what I could do is re
open that class and define methods on
so I could do something like class
person except now to make up okay so much and then put my 2s method
in there do that
or more conveniently
I think what I can do
is rely on the fact that I can subclass from an expression
as long as an expression returns a class object and this case
a subclass from that
construct a new class based on my personal check
but now house that method not just runs
nothing you can't do without the other techniques for
but these ability to extend the class and the ability to suppress from a class
object
are really quite fun just quickly
sir that is syntax unfortunately you can't override that operator
are
inheritance itself is not know if that's ok the question was is
this less than some kinda method that's called on the class object
that would be so nice walls but it's not
yeah be really caucusing she override it hurts
your wall
where are we
okay just real quick licks and I would think a couple on here
just one last quick thing including extend because again people get a little
confused about
what include an extent you have module
occurring at times if I include that module in the class
then I can
invoke
the instance methods that model alright
and so this account like mystique hilltop
particularly because in languages like C++ see shop Super Sport
include is a textual substitution it doesn't find something
and dragged in so quite often people
explain include by saying it takes the methods is that
and helps them to that class but it doesn't
and you can tell it doesn't because
if I was the fine
that meant that there right gets invoked
if I was to find it before
I do they include it still gets
yeah so the clothing has to be some were separate from Mike wells
and what's more it cannot be
might direct class because we know that that no
is in class today so how do we want to the right to get my methods
we know it has to be there so include hospital with funky
building about include is that if I create an object here
than ok a lot more joe M again and change it
even though I've already created my deal object here
speak here if not already created my
the object change in the module change the behavior
that the object something funky must be going on what's actually happening
is that his mind
mike d class MyClass whatever it might be when ice
use include in it Ruby inserts
what all those little weird funky classes single glossary like
has the immediate parent of my class
and its methods
all the methods that module I have to draw them
out here because this is separate to the module it does not make the module
my parents all the classes parent and it can't make much mccur
because I can include a model in multiple classes and so
the parent link has to be different for each other's so how was it really
creates
anonymous class like that and then using
the magic pointers makes the methods of this guy
the same as a method to my module if I then define
a new class and include that module in that class
then a new anonymous class gets created
its methods also sure that models but the table
that's why if I subsequently change the modern methods and that module
they get changed every single instances that class
but again there is no special case here
a method call is still want to the right
and then opt so
it includes them
I bases stuck in the mall so you aren't you got a new
a new one of these guys for each module includes right
the medical ask those at the bottom
your class and the models going up and effect it's actually
that's all those things where I can say that glibly it's actually worth playing
with that
and can play with it but discreet in the same name method
each wall and then comment in announcing how it works out
you find it works out singleton class
model that's a plus alright
so fundamentally this is the picture I would like to have in your head
what it looks like inside the room Ruby programmers runs we have objects
all these are objects ross's everything a real object
right all these are objects some objects whole
state used your program Pat so whatever that may be some object
all things are classes but again that no different to any other object
just have state wouldn't sure classes case
said methods have on some
about behavior continues are they have behavior
have apparently but that's your fundamental
object model all you have to do
to get better programming is understand
house elf works understand how selfish changed other biometric
up by another call or by class definition understand
the instance variables are always store in cell
and referenced in cell a spot wall
part 2 understand
the all method calls in Ruby are identical
there are no special cases every method cool
is right and then all you're inside a class object
right and then all and thats
all there is to it sense
cougar for the matter program
enjoy world
in

RailsConf 2016 - RSpec and Rails 5 by Justin Searls

(electronic music)
(train whistles)
- Ugh, RSpec.
All right, so, when you walked in you saw this,
that's me, that's Justin Searls,
but you can see how it's written by hand on an index card.
There's a story behind that,
this is not my talk.
Which is part of why I'm so nervous,
but really, please don't leave,
you're in the right place at least.
So you just stay where you are
and I'm gonna do my best despite this.
This is actually (yells)
not acceptable.
I'm being trolled so hard.
Okay so, this is not a bait-and-switch.
Most, I've spoken at RailsConf two times before,
and I intentionally wrote abstracts to get in
through the CFP and then I talked about
what I wanted to talk about.
So, this is not a bait-and-switch like those two.
It wasn't intentionally that, it is now.
This was supposed to be Sam Phippen's talk,
everyone go follow Sam, he's great.
Sadly, Sam is in the hospital,
so he wasn't able to give this talk,
and that's why I'm here instead.
But it's a British hospital, so he's just in hospital.
(audience laughs)
So send your good wishes to Sam.
Why me, why am I here?
Well, Sam likes to give conference presentations
wearing my company's branded t shirt, Test Double,
so people are often mistaking him
for one of our employees such that
he actually now has intro slides like,
I do not work for Test Double.
(audience laughs)
But I love them and also Searls,
which I heartily appreciate,
we love you too, Sam.
That's why we're here,
you're a great member of the community.
So this talk is going to be Phipp'n great.
(audience laughs)
Only problem is I finally understand imposter syndrome.
So, I've got a little bit of imposter syndrome
because I am a literal imposter today,
in three main categories.
One, I am not British.
And as we all know, as Americans, of those us in the room
who are American, everything out of British people's mouths
sounds a lot more intelligent, so I have that shortcoming.
And therefore today I resolve to use fewer contractions,
to speak with authority,
and to drop the rhotic R.
So let's practice this sentence together:
minitest is not betta' than RSpec.
(audience laughs)
All right, I feel better already.
Two, I lack Sam's glorious mane,
I don't have a big bushy beard.
Sam, of course, derives his RSpec powers from his beard.
This is obvious because why else would he have it?
So I have not shaved since I agreed to do this
at 7am Friday morning.
Some scraggles.
So I now know a few things,
based on the RSpec beard powers.
One, beards are itchy.
Two, RSpec.
(laughs and applause)
And three, what beard oil is.
So, if anyone, I forgot my razor, true story,
if anyone has some beard oil on them,
hook a brother up.
Third way in which I am an imposter today,
I am not on rspec-core.
Here is a little like, organizational chart of where
I fit into RSpec, that's rspec-core, and that's me
not being in it.
But you know what, apparently it's just not
a RailsConf without a talk from an RSpec committer
about RSpec.
So far, to date, the only RSpec thing
I've committed to is this talk.
So I just decided to become an RSpec committer,
right, it sounds like a good idea.
So, let's get started.
I'm gonna make my first RSpec commit, right here.
(audience laughs)
I am so committed right now to RSpec.
All right, so I'm just gonna push it up, access denied.
So I tried everything earlier in the hotel.
(audience laughs)
So let's try one more time, always works.
(audience laughs)
You know what, you get this error message
also when GitHub's down, so it's probably just that
GitHub's down.
So as this talk's resident RSpec committer,
I have some startling announcements to make.
I'm here ready to announce
the future of RSpec for you today.
Current version of RSpec is 3.4.0,
I'm here to announce the next major release of RSpec,
RSpec five.
RSpec 5 is gonna be revolutionary
because we have some really awesome headline features
that are very convenient to me and my purposes.
The first, TurboSpec.
(audience laughs)
Let me tell you about TurboSpec.
(audience laughs)
Yup.
TurboSpec dumps the ObjectSpace into the cache,
into memory, after running every single one
of your before hooks.
It does this so that it can cache
each nested example group's setup code
so that you don't have to run it across all your tests.
And then if you run the RSpec CLI
with tack, tack, turbo button, it speeds up your testa.
TurboSpec is gonna make all of our
slow RSpec suites way faster.
Warning, it doesn't work if your application
has side effects.
(audience laughs)
But for the rest of us it's gonna be just awesome.
I've another feature for RSpec 5 that I think
is gonna really just make true believers of RSpec happy.
Spec Specs.
(audience laughs)
You just create a spec of type spec,
and then you can say things like,
hey this model order I expect it to have five specs.
(audience laughs and applause)
I expect order to finish within about two hours,
to have 95% code coverage,
to limit the nesting indentation to just three contexts,
to usually pass,
(audience laughs)
and to be good code.
I don't know why they didn't have this in RSpec 3,
it's in RSpec 5.
Remember, it's important to spec spec
your spec specs, people.
Let's not get lazy.
Obama's saying things.
Audio doesn't work anymore because of their shenanigans.
Let's try one more time.
All right, what he said was, "Justin just give it a rest."
Damn it.
(audience laughs)
I'm gonna be, now I'm not gonna sleep tonight.
So, thanks audio.
All right, so I'm still, anyway, regardless,
I'm not sure if I'm cured or if I'm still impostering.
You know, I am not Sam.
If you don't know me, this is what I look like on Twitter
when I'm getting retweeted for saying terrible things.
That's me, Searls, I'd love if you became my twitter friends
and got me some feedback about how things are going.
I know it's not great so far.
This is the Justin Searl's marriage simulator,
basically it's just you sitting across a table
with me looking at my phone and making slanted faces.
(audience laughs)
So we can all emphasize with Becky Joy a little better.
And this is me on brand, I help run a software agency
called Test Double, our mission is audacious.
We're just trying to make the world's software less awful.
And I'd love if you got us any feedback,
hello@testdouble.com.
All right so, again, talk title, back to basics.
Rspec, Rails 5, what's there to know?
By the way, side bar,
did you know Sam rejected my RailsConf talk?
I just thought I should mention that,
because I am supposedly honor-bound
to cover all of this Rails 5 stuff.
Because it's important to cover
for the purpose of the program,
which I took with just nothing but grace.
So Rails 5 stuff.
My first question to Sam via text message
on Friday morning was will RSpec just work with Rails 5?
No.
(audience laughs)
and he was saying it as an implementer, right,
he's thinking about all the work that they needed to do.
Because obviously if you've ever maintained
a gem, newsflash, major Rails releases break gems
in surprising and myriad ways.
I went and searched for just open GitHub issues
that are demanding Rails 5 support.
Just search for it, and you get a whole lot of
salty randos saying hey, Rails 5 is not supported.
No description.
Give me Rails 5, you owe me, come on,
gems, work, work, give me.
Rails 5 is not even out yet, people.
(audience laughs)
So if you know a maintainer go give them, maintainer a hug
because, seriously, Rails major release upgrades
are big work.
RSpec considers this to be feature work.
They don't wanna break, make any breaking changes,
they want you to be able to upgrade very gracefully,
that's why they respect semver as much as I don't.
They're at 3.4.0, it's gonna be 3.5.0,
which means that they have to keep it running
for older version of Rails, but also new versions of Rails.
So I hope that you like, take a moment,
to thank the RSpec team for their thankless work
because everything that they're doing here
is behind the scenes.
But there is one change that we all have to know about,
which is, is it true that like, functional tests
and controller specs are really deprecated?
Well, yes, it actually is true.
They're going away with Rails 5,
they're deprecated, at least soft deprecated.
To which I say finally.
If you don't write controller specs by the way
feel free to just play with your phone
for this portion of the talk.
If you do, it all started when DHH opened
this issue saying, you know,
the mechanism for us making, verifying that you
assigned a particular instance variable
and a controller, making sure that a particular
template was going to get rendered,
those are testing implementation,
those aren't really valuable.
Let's deprecate functional tests.
And I feel like he was absolutely right.
That was a really good point.
And, of course, if you disagree you might disagree
just because you write controller specs,
but here's my beef with controller specs.
This is the testing pyramid here.
At the top of the testing pyramid
it's just a way to illustrate user full-stack tests
that call through everything in reality,
and stuff at the bottom, these are just unit tests.
Stuff in the middle are difficult to explain tests.
And that's what controller specs are.
So, the problem, right...
The opportunity.
Oh my gosh.
(audience laughs)
All right.
I'm so glad to be at one of those like,
just chill, go with the flow kind of guys.
All right, so.
The problem with controller specs at this level is that
above that point in the pyramid,
there are untestable things that can break.
And so they are only of limited value.
And everything below it, the messages that you get
are gonna be unclear reasons why things are gonna fail,
because it might be something way, way deep below you
that is actually the root cause of the failure
and the error messages aren't gonna be very helpful.
So it helps you in that very skinny way,
but I don't know how much value that really adds.
Another thing about controller specs that sucks
is that they were a lie to begin with.
Their API implies that a request is being made.
So if you've got a controller,
you do like, get index, like you're actually
making an HTTP request, and then you have these
assertions like you render this template,
or you redirect it,
or you have this http status.
Oh look, I'm making a request!
Wrong, it's just like, that's just really silly
sugar of a façade and it's just invoking
you controller methods.
Which means all this other stuff is not happening,
like middleware is not getting invoked.
So your controller specs might be passing,
when your controller is totally busted.
But they're faster!
And that's why they exist.
And they might be faster at run-time
but in my experience they're much slower at fix-time,
they're just a maintenance nightmare,
for all of that no value that they provide.
So, but, you know, despite the criticisms
controller specs, semver right, so RSpec is promising
not to break our tests with Rails 5.
The way that we are doing that,
the way that you do that, all that you have to do
is add this gem to your gem file
called rails-controller-testing,
which will reintroduce the functional testing bits
that RSpec Rails needs.
And then meanwhile the RSpec team is doing the
hard work to make it seamless.
It's my understanding,
Sam Phippen's doing a lot of that work.
And I hope that's not what put him in a hospital.
So thanks to Sam and the RSpec core team.
If you already have a lot of controller specs
stop writing those now.
There's stuff that you can do
instead of controller specs in the future.
Here are some alternatives.
One, you could write full-stack feature tests
that test that everything's fully working
when everything's really integrated.
You could also do nothing.
I do nothing, I have not written a controller spec
for seven years.
And you could also do request specs,
which are very similar, we'll talk about those in a second.
Because request specs are like honest versions
of controller specs.
They map to many tests, integration tests in Rails.
And the reason that they're honest is that,
the API looks the same, and the assertions look the same,
except it actually exercises the routing,
the middlewares, and the views,
so if something blows up, you know it's a good blow up.
Another cool thing is because it's using rack test,
you have access to the response body
and you can make assertions on the actual response
that's generated instead of all this
weird implementation stuff.
When to use request specs instead of controller specs,
or nothing.
Specs that asset like a complete API response
like if you've got like a json API
and you can assert everything that it does,
cool, request specs are probably
the right layer to test that.
Specs that just assert your assigning certain ivars
or rendering certain template, eh,
it's needlessly coupled to the implementation,
probably don't need a request spec.
Specs that assert HTML that comes out of the response body,
probably not a good idea unless
your app has absolutely no JavaScript.
Which is probably unlikely.
So that's a bit about request specs, controller specs.
Third bit.
It was in the abstract, right, that we're gonna
learn how to test ActionCable.
So does RSpec help us test ActionCable?
No.
Turns out that ActionCable testing
isn't built into Rails yet, there's an open core request,
and I assume that when that ships
RSpec will have a wrapper for it or something.
So just test through the browser for now
and make sure your website works.
All right, there you go!
You are now ready to RSpec with Rails 5.
Thanks very much, Sam, for trusting me with your talk,
there's nothing more for you to see here,
you can close Skype, Sarah, there's nothing
I think he's actually like, maybe here,
I think I see him waving actually.
Hi Sam!
Yeah, he looks excited.
Yup, all right, bye Sam!
(audience laughs)
So one time, Aaron Patterson's up in the front row,
one time I texted Aaron something and he tweeted it
and got a million retweets,
and I felt really salty about that
cuz I was like, no that way my random Internet meme
that I copied and pasted.
And he sent me this in response.
(audience laughs)
It's that fundamental attribution error.
It's Internet attribution error.
So this is my talk.
(audience laughs)
RSpec and Rails 5.
Why are you here?
Really, like, shout it out, somebody tell me.
Why you're here.
- Searls.
- No.
Next question, somebody, so why'd you come to this talk
especially if you didn't know who I was?
Okay, something RSpec related, anyone?
What's that?
(audience speaking)
Okay, thanks.
All right, thank you.
(audience speaking)
ActionCable, thank you!
RSpec cable.
Well I had two theories, cuz I couldn't
make the slides after asking you.
One, how the hell do I test ActionCable?
(audience laughs)
Sorry, for those people, cuz I don't know.
Two, I'm not happy with my test suite.
And now I have a third theory too, like, you know,
I'm new here and what the hell is all this about
because it's just like a lot of forensics
and who are these people?
I'll focus on the one that I can actually address,
which is what happens when we're still not happy
with our test suites?
Well, if you have this motivation
and that's part of why you came to this talk
maybe you were thinking like,
well RSpec might have a new feature
that'll help me hate my tests less?
Or maybe Rails has some new thing,
or removes a new thing, that will help
make the pain stop, make my test suite more sane?
I think that's a natural thing to do,
especially when you're in a conference,
we're here to learn about technology.
We're searching for tools.
And tools are easy, cuz we can grab them
off a shelf and use them,
but they're way easier than like,
critical introspection, asking ourselves hard questions like
maybe it's our fault that we have terrible tests?
There's two keys to happiness
with testing or anything in software.
One, the tools that we use.
Two, how we use those tools.
And it's not a two-step recipe.
There's a, it's like a, not a false,
it is a false dichotomy to like,
blame one side or the other.
Some people say like, oh well, clearly we just need
better tools, whenever we have a problem.
And some people have a disposition that says,
well no we just have to think differently.
We have to design harder.
Like if, the tool's failing us
we're not using it hard enough.
And that's not a good mental model either.
I like to think of it as like,
first there are people thinking,
and they were doing stuff and then they wrote tools
to help them do their job, and then the tools
our actual usage of them informs how we think about
the problem and it's this hopefully virtuous cycle,
this feedback loop.
So I do believe that tools matter, tools aren't everything.
But tools are important, and we're gonna talk about
how tools prompt behavior.
Some tools guide us in a healthy direction
to build good stuff.
Some tools enable our bad habits.
And some tools just are written to be
relatively low opinion, not very opinionated.
First I wanna talk about a tool that
enables a lot of bad habits.
It's a, you may have heard of it,
it's called rspec-rails,
and I feel like whoever invented rspec-rails was like,
here's our marching orders, we're gonna just
do whatever Rails does and then
wrap it with our CLI and DSL.
As uncritically as possible.
So, you got controllers?
Yeah, we can spec 'em.
Great.
Without thinking whether that was a good idea.
You got a testing pyramid?
We got a testing pyramid!
(audience laughs)
You want model specs, and controller specs,
and helper specs, and view specs, and routing specs,
and request specs, sure, and have feature tests too.
Just why not have all these layers?
And honestly as somebody who's,
especially when I was a novice coming in,
I was like, well clearly,
our tools are built for good reason,
they have a good reason for having all these
different tests.
Tests all of the fucking time, that's great, okay.
So I thought like, I looked at that and I was like,
man I got my work cut out for me to like,
live up to this seven layer nacho of testing.
And what I came to realize over through a lot of usage
is like, well, all those tests are very integrated.
Every single one of them will call through
to the database.
And additionally they're very redundant.
When I have a new model that I'm writing here,
and I make a change there, I have this incidental coverage
in all the tests above it,
so all those tests need to be updated as well.
And it creates a lot of like, low value work
just cleaning up all my tests.
So here's protip, here's how I use rspec-rails,
this is a secret.
My secret to using rspec-rails,
is I have this whole thing and then I blow away
all of them, except for sometimes feature specs
and sometimes model specs.
And then if I have any sort of Ruby that's like,
at all interesting, I'll write it in Ruby code.
And then I'll test it with plain old RSpec.
And that's the only way I've been able
to find sanity with rspec-rails.
But it's not the tool's fault per say,
but I had to fight that tool to get to this point.
I had to fight all the documentation,
and all the blog posts, and all of the arguments
with people about why I was having problems.
And that was not an example of a great tool experience.
Let me tell you about an experience
with a tool that I thought was really, really helpful
and great, it's name is RSpec.
RSpec itself is actually really awesome,
but I think that a lot of people have
a hard time with rspec-rails, and then they turn around
and they blame RSpec too, and I think that's
kind of unfair, it's worth it to like,
look at them separately.
So let's talk about what RSpec kinda cool.
First of all, I don't believe that RSpec
is a test framework, per say.
I think it's better to think of RSpec
as a framework for helping you to write better tests.
(audience laughs)
RSpec influences our design.
It was designed to do that.
You know, it was a response to x unit,
with lots of repetitive methods that were all
set up, like tons of tests,
set up, and action, and assert.
But what was cool about nested example groups is,
we can see the same symmetry like,
and have very terse tests that aren't redundant.
But we don't lose any clarity through
drying it up, that's one, my favorite thing about
RSpec style testing.
Additionally I love that the assertions guide,
the naming for our methods.
If I write this test and the thing doesn't exist yet,
by using this match or be silent,
it's going to assume that there is an instance method
called silent, question mark, on that class.
Which is a really handy way to like,
inform that the usage is like, sensible, like,
that's a natural name now.
Additionally, years ago, when I learned about let,
I was pairing with Corey Haines.
Corey is a really smart developer,
I really looked up to him and he's like,
let is great because it lets you call out
your setup stuff, create a new user,
and assign it to this method,
and even better, it's lazy, lazily evaluated.
And I was like, I don't know Corey, I worship you,
so lazily evaluated sounds sweet,
that's great, I'm gonna use let for everything.
So I've used let a lot.
And then another feature, let bang,
which will eagerly invoke that block,
it has this interesting thing because like,
people generally find let bang by being like,
well I want this to run in exactly this order.
I wanna make sure that it invokes.
And so Jim Weirich and I paired,
and he looked at my code base and he's like,
dude, dude, you're doing this totally wrong,
don't just use let bang for absolutely everything.
It's like, there to draw out your attention
to side effects in your code.
It should be minimal, you should have them
very, very sparingly like,
if you need to have a side effect
in order for your code to work,
that means that you have this coupling of state
not just to the arguments, but to other stuff
happening in the system.
So like, that's why there's a bang,
it means don't do it.
So, that was an interesting conversation
that I never would have had if it wasn't for RSpec.
Additionally RSpec reduces friction.
The CLI is great because it's really
you know, convenient, easy to use, pretty obvious,
helps you focus on just what you wanna run,
has a good output, and that's all work
that I'd have to do if I was building my own
rake tasks and my own sort of like,
testing CLI stuff on every project.
And I love RSpec's built-in reporters.
Oh my god we're at thirty minutes
because of all the AV stuff.
Please don't leave.
All the reporters you need,
so that you have all the CI stuff that you need,
there's so many RSpec plugins,
I love that, I'm get to focus on just my tests,
and not the stuff around my tests.
Additionally RSpec fosters empathy.
The API is designed to like,
let you have a place to write in
what the heck you're doing,
describe, you know, the slide,
and how it compliments RSpec.
You have this opportunity in there
to tell a little bit of your story in a way
that's congruent with your tests.
Another thing I love is that it shifts your perspective.
So RSpec has a domain specific language,
it does not look like normal Ruby,
and that is a level of indirection.
However, it forces me to think of my methods
not just as methods, but like, outside-in,
what's it like to use them?
What's it like from the perspective of a stakeholder?
What's it like under a different context?
I really like the DSL for forcing me out of
just thinking of just methods and classes.
Another tool, talking about tools prompting behavior,
it's possible to write that just don't have
a whole lot of opinions.
Minitest is a good example of one such tool.
And it has a different priority than RSpec,
an analogy I picked up from Aaron this week
is you can think of minitest as a race car,
it's why DHH uses minitest by the way if you don't know.
So it's lean, mean, it's essential,
it's only what you need to get your tests written.
It's all pure Ruby.
Except it has these hard bucket seats.
Versus RSpec, a luxury sedan,
with a lot of knobs and dials
but it's mostly full-featured and
quite comfortable to ride in.
So, if you want, you know, a comfortable seat,
RSpec offers you this rich, Corinthian leather experience
that you can just sit in and feel comfortable.
The zeitgeist right now,
and by the way if you don't know the word zeitgeist,
it's a German word for time snapchat.
(audience laughs)
The zeitgeist right now is saying that
minitest is really hot.
Like when I talk to all my friends
a lot of them has dropped RSpec and started using minitest.
I think it's just like, really popular right now
and I think that one of the reasons is like,
people generally spread fear and uncertainty
and doubt about RSpec, that it's too verbose,
it's bloated, it's slow, it's too much indirection,
it's better just to write pure Ruby.
You ain't gonna need it.
I'm here too, I use minitest on a lot of my projects,
I like minitest just fine.
I like that it doesn't have very many opinions
and it gets out of my way and I can just write
just the tests I want.
But of course, I carry with me the fact that
I actually have very finally, after years and years,
I have my own testing opinions that I know
work very well for me, and I can write tests
without getting myself into too much trouble, usually.
But if you're not a testing expert,
and you don't wanna be a testing expert,
or if you're on a team with novices,
what I would suggest is like,
remember I learned a lot discussing RSpec
and grappling with its API and its features
with past teammates.
And I think that you might benefit from that too
if you haven't had that experience yet.
So yeah, on one hand RSpec takes longer to learn.
But when you learn how to use RSpec
you're also learning stuff about design and testing,
and so maybe that's not so much a bug
as a feature in some cases.
So if you're still not happy with your test suites,
I suspect that you might be looking for a tool
to solve all of your problems when instead
we can use our brains and use thinking instead,
and change our approach.
Oddly enough, at RubyConf last year,
I gave a talk on exactly that,
you can find it called, is.gd/stophate.
It's called How to Stop Hating Your Tests.
And it's not about tools, it's just about thinking.
All right so, in the time remaining
I'm gonna get a little bit more meta.
Why are we here, really?
The fact that anyone came to this talk worries me.
(audience laughs)
I would have not have come to this talk.
Let me explain, let me back up.
First of all, giving somebody else's talk
is a lot like testing their code.
Cuz I've had to like, open up all of Sam's work
and his notes and stuff and try to understand
what he was gonna say here today.
So, if you see something confusing,
when you're looking at somebody else's code
and you're trying to write tests for it,
or trying to review it,
it's easy to think they are obviously a moron.
So it's important to assume that the author is smart,
and intelligent, and had reasons.
Meanwhile if you see something that's
obviously awesome, great.
It's still your job to put on a critical hat
and investigate it anyway and ask the hard questions
about why we're here.
So let's critique this talk.
Not the stuff that I said, just the Sam stuff.
Stuff I said, is fine.
(audience laughs)
This is the abstract, I assume you've read it,
I won't reread it or anything.
This is his abstract, this is the first thing I read
when he texted me to see if I could give this talk.
This is my opinion of the abstract.
People like peanut butter, people like chocolate,
slam 'em together, rspec-rails.
This talk I felt like I read the abstract, I'm like,
this could be a six paragraph blog post.
And so the next thing I did was I googled
rspec-rails 5, and found Sam's six paragraph blog post.
(audience laughs)
Yeah I was just thinking, I was mad, I was like,
why was this talk selected here?
How did this talk fly through the CFP process
without any criticality whatsoever?
Like, that just doesn't seem right.
Now granted, my talk was rejected,
and I'm a little bit biased, I might be a little salty.
But when I thought about it, I think that the reason was
that this was a safe talk.
This is a comfortable talk.
This is well within everyone here's comfort zones.
I use RSpec, I use Rails, let's find out what's new.
Great.
But I feel like that comfort should scare us,
because when we're in a group like this
that's maturing, we're getting up to
major version numbers like five, you know,
comfort can breed complacency.
So RSpec, if we're just content with where things are
and we're pretty happy with RSpec and we're just happy
to see, you know like, little tiny tweaks here and there,
make sure it continues to support stuff in the future,
you're not writing blog posts about this new RSpec thing,
you're not writing new tools.
You're talking about RSpec less.
Even if RSpec does everything you want it to do.
Minitest meanwhile lately, I've like, zeitgeist,
I've seen a lot of people talking up minitest,
writing more plugins, educating people
a bit more with blog posts.
And as a result it's getting a little bit more attention.
So it's, new person walks into the room,
they're gonna see people talking about minitest
more than RSpec, they're gonna tend to go towards minitest.
Not RSpec.
So, this reminds me a little bit of a similar dichotomy.
Rails, Rails is pretty mature now, it's over ten years old,
it solves the problems that it solves really well,
and it's pretty well know what it's good at
and what it's not.
So people talk about Rails a little bit less.
Especially all of us busy getting stuff done
and building things, we're not out there
advocating Rails anymore because we get to use
Rails at work, which is itself fantastic.
However when you look at jobs,
Rails jobs are on the decline.
They're not just slowing down, it's negative growth.
There's this other thing,
the technology that shall not be named.
(audience laughs)
Everyone's talking about node js.
Like it or not, 900% year over year
growth in jobs on indeed.
There's a lot of activity there,
and it's not about, this is not a contest
of who's the better technology,
or who solves stuff better.
It's what's the front page of Hacker News?
So my challenge is, thinking about this talk
and why the hell we're giving this talk and why we're here.
(audience laughs)
That was ironic.
(audience laughs)
Cuz that's one of our options.
The other option, if we're not willing to be uncomfortable
is we're gonna see Ruby jobs start to dry up.
And there might be, you know, fewer people
at RailsConf 2018 than this year.
Another way to think about this,
is if you're not familiar, Ruby Together
is a non-profit that pays people
to work on Ruby open-source.
Another way to think about this is ask,
what were the conditions necessary in order
for Ruby Together to seem like a necessary
and good idea?
Well, when an ecosystem is popular,
everything is easy, cuz there's just, you know,
wave after wave of person on the Internet
who's gonna write open-source for free,
just for the ego, just for the fame,
to be attributed to the new, popular thing.
Also easy, sponsored stuff.
Like Oracle backs Java.
Java's not gonna go anywhere because
Oracle's incentivized for Java to be successful.
Google is not gonna drop Go, unless they feel like it.
(audience laughs)
I already dropped the mic, but...
Javascript can not die.
Because multiple vendors have
staked their businesses on it.
Every single browser, lots, Javascript is not gonna go
anywhere, so it's a pretty safe bet.
We talk about RSpec, it's mature.
At this point.
And I don't mean mature as like a four-letter word,
mature means mostly done.
Bundler is mature.
Rails is mature, Ruby is mature,
they mostly do what they need to do
to do their job well.
But it means, as a result, that when you maintain
a popular gem like RSpec, it no longer makes you
rich and famous necessarily.
And the ecosystem, the stuff that they had to do
just to make RSpec continue working with Rails 5,
is almost all stuff that you don't actually see.
It's all internal, it's legacy code refactoring.
No one really wants to do that.
And so the reason Ruby Together needs to exist
is because the energy and the funding to keep Ruby
competitive, isn't there otherwise.
And that is disconcerting.
Cuz Ruby Together isn't gonna ever be big enough
to solve that fundamental systemic problem.
So let's talk about my real job, sales,
I spend a lot of time talking to business people
about software solutions and
building software apps and stuff.
And entrepreneurs that I've talked to
are always talking about certain technologies
that they hear about that are advised to them like,
the mean stack, like Mongo, Express, Angular,
and by the way, when people like, I've talked to
multiple business people this year who are like,
yeah well we're gonna build a new application,
we're gonna do it all in Angular one dot x.
Like, people are teaching business people,
oh you don't want Angular two, just stay on one forever.
Like, I don't get it.
We're just gonna wait, wait it out.
And Node js, the so-called mean stack.
A lot of entrepreneurs are pushing this kind of stuff.
Another one, lotta people are just assuming
based on trendiness, Node and React are just the way to go.
You know who's talking about Ruby and Rails nowadays?
Out in the marketplace?
Like, has the ear of CTOs and directors in engineering?
People spreading fear, uncertainty, and doubt
because they have their preferred upstart technology
that's faster or whatever.
And what those businesses are hearing,
is that there aren't enough Rubyists out there.
That the Rubyists that do exist cost too much.
That Ruby is slow.
And that RSpec doesn't scale.
Either at runtime or operationally.
Now if you're in the room you're like,
no, no, no, Ruby's fine, this is okay.
But I think that this is like a, real important
bit of anec-data from the life of Justin Searls
we all need to deal with to help solve
my consulting sales problem, so.
(audience laughs)
Cuz I don't like sales.
But that's why it's so frustrating,
is Rails is still the best choice
for entire classes of applications.
But because we stopped saying it a few years ago
businesses stopped hearing it.
People only share new stuff,
that excites them, that's novel.
If you were to discover immortality today,
it would drop off the front page of Hacker News
after a week or two.
People wouldn't be talking about it,
they'd find some new shiny thing,
they'd be talking about React Native 1.0.
(audience laughs)
And not that you just, you know, defeated death.
Even though that thing is way more objectively better,
it's not novel after a certain bit of time.
So the dilemma, right?
Ruby is no longer new, Ruby is still good.
We gotta do something so Ruby can remain relevant
and we can keep working on Ruby at work.
What's the we do something part?
Remember, Ruby's mature.
It does its job mostly well,
and one thing that I think our community,
that technologists need to get comfortable with,
is that it is okay for tools to be mostly finished.
It is okay for software to just mostly do its job,
and be good at what it does.
In any other industry it would be ridiculous for us
to say otherwise.
That like, oh well, that's clearly obsolete now,
because it's not, you know, super active
and they're not adding new features.
At a certain point it just does what it needs to do.
Remember I said that the keys to happiness
were our tools, we all like Ruby, we like Rails,
that's why you're here,
And how we use them.
So maybe it's time for us as a community
to deemphasize the tools,
and start talking more about how we use those tools
to accomplish really cool stuff.
Cuz there's all these evergreen problems in software.
There's all these problems that we're never gonna solve.
We're never gonna solve testing.
We're gonna just get asymtotically better each time.
We're never gonna solve design,
because we're always gonna find new ways to design code.
And human issues are never gonna be solved either.
Right?
How our code communicates its intent
to its reader is never gonna be solved.
(audience laughs)
I swear, I get like five bonus minutes.
Sarah, can I have, a minute?
She's nodding, very tepidly.
(audience laughs)
So we gotta tell stories,
that help people solve problems,
in ways that are more than just
look at this new shiny bauble.
And if you love Ruby, tell your story in Ruby,
and associate it back with Ruby.
So that Ruby remains known as a community of people
who really get object-oriented design right.
Who get testing right.
Who get community and inclusiveness right.
Being known for those things
and having people talk about those things
are enough to keep us relevant.
And when you think about who's job this is,
remember that most of the people
who made Ruby so famous in the first place
don't write Ruby anymore.
Their chapter is complete.
Most of them have moved on to other ecosystems.
Some of them are no longer even with us.
And that means that keeping Ruby relevant
is not somebody else's job.
I hate to break it to you, but the fact that you
show up to a conference called RailsConf,
in a room that holds just a couple hundred people,
means that you're one of the top couple hundred people
who's job this is now.
To keep Ruby relevant, if you care.
So, my message is make Ruby great again.
(audience laughs and applause)
#MakeRubyGreatAgain.
(audience laughs)
And tell your story, we don't have the time
to talk about it today.
Use this hashtag and tell me something
that you could do to tell a story
that might change something.
That might have an impact on others,
and might convince them that Ruby is a better solution
than the technology that shall not be named,
for whatever it is that you're doing.
Again my name is Searls, I'd love to be your friend,
I'm gonna be here for the rest of the week.
If you wanna help us in our mission to fix
how the world writes software,
consider joining Test Double,
we're always hiring great developers.
If your company's looking for senior developers
and you're struggling to find people to add to your team,
our developer consultants
are great senior developers who'd love to work
on your team with you and build stuff alongside you.
If you don't want either of those things
but you want a sticker, I've got stickers too.
And most importantly, thank you all so much for your time.
I really, really appreciate it.
(applause)
(electronic music)
(train whistles)

Saturday, October 01, 2016

Rails Pacific 2016 - Make Money and Enjoy Freedom Creating a Software Business by Ryan MacInnes

I'm here to teach you about how to start a software business
i should mention i'm from los angeles california by the way
first of all why should you trust me i am the founder and CEO of juicer . i owe
one io is a aggregate our social media aggregator an
embeddable social media aggregator
so what the hell is a social media aggregator essentially would you throw
out you to do is to connect all of your brand of your personal social media
accounts and it will automatically pull in any new post you have and you give
you a little snippet of code simply can put in your website so it'll display all
of these posts and beautiful feed
so here's an example this is actually from the Golden Globes com you guys with
the Golden Gloves is but it like sort of like a crappy version of the oscars in
the US but still very popular and actually this this feed itself
about 20 million views over two day . but you can see the different social
media types you get twitter facebook Instagram etc so it makes it really easy
to connect all these accounts and embed them into website it also often plan to
use their live events and concerts
you know with hash tags so people can you can see a sort of aggregated to be
anywhere you are and participate in a conversation and every once again
so firstly why would you want to start your own business all
as William all its best side
freedom is the number one and most obvious reasons start your own business
for a couple examples they spent the last two months of the last six living
in Los Angeles where I live
the other four months I spent traveling around the world
I never set an alarm I get to work whenever the hell I feel again and I get
to live wherever I want as well
secondly also pretty obvious is that the amount of ever you put in is linked to
your pay and a full-time job there's no incentive to work to the best of your
ability necessarily apart from worried about getting fired so general you will
work to a level that it will keep you from getting fired
but there's no incentive to go above and beyond also your salary is significantly
less than the value you provide your employer and so what this means is that
you are good deal for your employer or you cost less than you are bringing in
for the company and this is especially true for developers who can easily work
earned the business they work for millions of dollars and i'm willing to
bet that your salary is a millions of dollars
finally no one's ever gotten rich working for somebody else
not the being rich is important and it's certainly nice but it's really nice to
realize that your earning potential is limitless compared to the five percent
yearly raise you can hope for at your job or ten percent raise you can hope
for from get this from switching on
obviously there's a few guys like a finance and that sort of thing and make
over a million dollars here but most developers them
so firstly i'm going to talk about my history prior to juicer just so you guys
can get an idea of how what led me to starting juicer
so I guess that are a degree in microbiology and i started programming
because i wanted to build a product and i couldn't convince anyone else to do it
for me and i was a college student so I don't have any money to paint one so i
got turned on the rails and I build the product
well really what i did was i slowly learned how to program built in rails
didn't really know what I was doing
finished it through it all out sorry overbuilt it a lot better and then sort
of launched a little bit
send it to some of my friends and i think i got maybe about a hundred people
to sign up for it but with that led to was one of the people who signed up with
somebody I don't know and he said hey like the site you build can you build me
a site as well and i have five thousand dollars to pay you with at the time I
said mommy I'm sure but inside I was screaming because no one has ever
offered me five thousand dollars for anything in my life at that point and so
I felt the guy is like and after that somebody else contact me and you know
slowly but surely this is turned into a lucrative for some lucrative side career
as a freelancer
so I I started realizing the in my free time I had a full-time job this whole
time as well and just building sites when I good or when people wanted me to
start doing a little more consulting work a little bit more serious sort of
realizing i guess and whenever I had free time I would build random various
products in my what you know whatever sort of idea that came to my head
so the rest of this talk I guess is going to be structured with sort of i'm
just gonna talk about what would like to do sir where did I come up with the idea
and how do I build it and you know how do i promote it and how do we get to the
point where at the same
I'll talk to about the point we're at today to at some point as well
so the first thing you need to do when starting your own business has come up
with an idea and this is arguably the hardest thing of the whole process
coming up with the idea of a juicer worked was I had a string of freelance
clients for a long time who asked me to put a social media peed in their website
they wanted to aggregate all of the different social media accounts and put
them on the website so the first time a client asked me to do this i googled
social media bead and i found a service they did this already and I said great
I don't have to build it myself somebody else can do it so i found a service and
services called teams and they charge ten dollars a month to put a social
media bead on your website so i got the clients to sign up for it and they doing
on the website name is great and I had clients after client and the client
would ask me for social media feed on their website so i always brought them
back to 10 times those ten ten ten ten dollars a month it's great
and then in about half way through 2014
I had a freelance client who was that hey I want to watch me pee on my website
is a great let's go to 10 and i went to tent i have probably been there about
six months or style and I found that they had raised their prices from ten
dollars a month to two hundred fifty dollars a month to mention - they've
sent raised their prices to five hundred dollars a month and they may have raised
even higher at this point so the client obviously this idea that we can pay for
that we're not going to pay that much just have a social media and be on our
website but can you build it for us
I light bulb went off in my head I said not only I can build this but what I'm
going to do instead is I'm going to build a service and you guys are sign up
for it
so that that's sort of where juicer came from and i had my first client before I
you know a single line of code
so now i'm going to talk about a couple of different ways
a couple of different ways you can come up with ideas hopefully the first and
most obvious is to solve your own problem
and so you guys are all developers then you've probably seen a myriad of
developer tools out there the sort of been started as products that will
hopefully make your life easier
so this is sort of the most common route taken with developers is solve a problem
you have
and this is great because you're very close to the problem so you have a good
idea of what the solution should be the problem of course with this is that it's
very crowded market there's many many developer tools and I think developers
are especially used to being a bitch sort of startup ideas and product ideas
and we're a little bit numb to it
the second way to do this is to solve a problem for others
so what what i mean by this is somebody who has a problem that's not a problem
that you share
so for example maybe you decide you want to build a restaurant reservation
management tool you guys presumably don't own restaurant so this isn't a
problem that you have specifically which can be great because you can really sort
of tap into markets that don't typically get the sort of attention that
oftentimes like developers down
but of course the problem with this is that you're further away from the actual
problem and the only way to really get to the core of what the problem is that
you're trying to solve is to talk to your customers and oftentimes the
constant with the customers think they want and what they actually want are
very different and sometimes have trouble communicating that
and thirdly which is sort of the route I took producer is this other problem for
something up so i have many many clients who all wanted social media feeds and so
I knew that this was a market that existed because somebody out there
needed multiple people i don't need it
so at the very least i thought i could sell these two other developers who have
the same
the same problems I do is that their clients are asking for social media
feeds for the website but they they can pay five hundred dollars a month to
these so when you come up with an idea i think is very important to start small
and what I'm talking about here is starts start with a small idea
so you want to build something that only a few people need but those people
really need it
so I didn't build a social media aggregator because i thought everyone in
the world makes the social media aggregator but there are certain
businesses that would like to include something like that on their website and
so I thought I would build something like that because i know there's lots of
businesses out there that have this need
but they don't have five hundred dollars months to throw the problem so I mean
so the next point I'll make is that I don't even get something to make it
better to make something that a few people loved a lot of people like so
what I mean by this is sort of the same thing I was talking about before is
focus on a leash and a small niche is good and it seems counterintuitive
because you when you focus on each it doesn't really seem like there's
anywhere to grow but i'll remind you that Microsoft started as a by creating
a basic interpreters were at the altar computer and seventies so looking like
this up now and they started with extreme
the next thing when coming up with an idea is to not worry about competitors
and I think the normal reaction when you see somebody else is already doing an
idea that you have
it's not to bother I think it's very important to ignore this feeling betters
me a couple things competitors mean that there is a market already so that if
somebody is doing the authority it means that there's a need for this out in the
world
Apple isn't the first company to ever make a computer by any means but they
did the best and are they're arguably the most successful computer company in
the world and juices started out with just a single competitor which was 10th
but it turns out there's a lot of companies out there that do which is it
does like me way more than you think there's got to be 50 plus in the world
and if I known that when i first started i probably would have been extremely
discouraged but luckily I was pretty lazy and didn't do very much research
and I mean so what if i had it was it's entirely possible that i wouldn't have
bothered but i'll tell you what it doesn't matter because there are a lot
of competitors out there but users doing just fine once you come up with the idea
i think it's very important that you name it and it seems very counter
intuitive as well but there's a few reasons you want to do this one is
because when you come up with a name for your product that makes it real
it makes it more real in your mind and you can start taking a little bit more
seriously
number two we get to the next step which is built it you're gonna be typing my
name a lot
when you program it so it's good just so you don't have to go do some search and
replace it if you decide you're changing them later
and finally it's good to have a do domain they have already purchased that
way when you want you can launch immediately and you don't have to sort
of lawful over what we're going to name in or what domain we're going to get
something is very important to sort of do these these relatives seemingly
simple tasks first before you write a single line of code
so the next step and the part of the you guys will excel at is build it so i
should note here that I'm not an especially good developer but what I am
good at is sort of starting a project from scratch and seeing it through to
some sort of deployables safe
I'm not going to talk too much about how to actually program because it's very
highly dependent but I
if you guys don't have a lot of practice or starting a probably starting the
project from scratch and getting it to a boil state then i highly recommend just
giving it a shot and trying it out because I know like you guys were pretty
big companies you probably a very specific tasks we work on you don't
necessarily get to work on the whole application
so the first thing I'll say about building it is
start small again OH - OH the next thing start small quite a bit and what you're
building here is the smallest possible possible product and you've probably
heard the term before MPP which stands for minimum viable product and what that
is is a product that provides the the most small atomic unit of usefulness and
obviously defining that is very hard to do
depending on what it is you're trying to build but I think it's really really
important to keep it as small as possible and so when I build juicer
I I built it in rails and I built using javascript and I knew you had to do a
couple things because I had a client telling me specifically what I needed to
do you need to have facebook twitter and instagram integrations and it needed to
be able to embed in their website that's all the client cared about but I needed
to do a few more things so that the client could then sign up for it so it
had to have a web interface had a complication and had to have a stripe
integration so that I could accept payment for my customers and has it that
was all I did
next thing I recommend is to design it yourself and I know this may be a
horrifying but to some of you but I promise you it's not too bad you all
learn how to be developers so i can assure you can all learn how to be
designers as well first I'll give you a couple of recommendations when it comes
to designing things but my number one thing is no bother with photoshop just
design in the browser using CSS if you guys don't know CSS you can also learn
that very quickly and easily use a couple basic design concepts like white
space and alignment
I won't go into too much detail about how to design something well because I
don't know honestly but you can make something look decent announced and this
is really important I think to design it yourself because it will really get you
into the nitty-gritty of how it should work
and what's the ideal user blow and how high did you decide to work overall and
it will really help you connect to the user your customer
hopefully and give you a sense of what they have to do to get your service
toward the next thing i'll say when one building it is to start download
deadline
I think this is really important because it's really easy to keep working and
adding features and doing more and more and really putting out the concept of
launching because i don't know about you guys but its developers the thing I'm
most comfortable doing is programming and all that other stuff is not
programming and the more I can keep programming the better in my mind
so for a few general rules of thumb I'll say if you have if you have a full time
to dedicate to your business that you're starting give yourself two weeks to get
too many people in that sounds like an insanely short period of time and if you
don't if you have a full-time job and you're going to do this interested in
years
three-time yourselves for weeks anything else after that
throw it out if it's if if you can't do it in that time
it's not important for the MVP and this will really help you focus and sort of
lean it lean your product down to exactly what it needs to be so the next
step after you build it
its launch it and i highly recommend launching it as soon as possible you
want to get this thing out in front of users and have users using it or not
using it
get an idea of what your user base how your user base is going to respond to it
and they are at all
so i'll talk a little bit about how i launched user so i originally launched
juicer and I got my one client to sign out behind integrated in their site
pretty quickly and then i decided i want to promote a little bit more so I went
to read it and I went on to two separate it's because the first thing I did is I
thought about who are my clients and in my room I customers and my mind
number one client was other web developers like me
other consultants or freelancers or people working companies who have been
tasked with heading a social media feed to a client's website
number two was social media marketers themselves so go directly straight to
the source
so when i read it and i found two subreddits that are exactly that's our
webinar social media and so from there
somebody found the site they liked it and they posted product onto and I don't
know product on was at the time this is mid-2014 so I think they have just
launched so I remember somebody telling me it was on product and I was like a
look at and I kind of told me like it was a really big deal
ok don't know what that is exactly by product and actually turned out to be
really great
so hopefully i can give you to use or general rules of thumb that I've learned
from this
but the most important thing I think it's a figure out who your customer is
and where they are and this sort of all comes
it's really kind of all part of step 1 which is coming up with an idea but it's
really knowing at least trying to formulate your head
do you think your customer is and I'm figure out where they are so i guess i'd
read it is a great place for that because there's a subreddit for
basically every person every type of person or every career so chances are
you'll be able to find a subreddit that pertains to your customer race over to
use hacker news
news ycombinator com which is really great if you're building a sort of
programmers centric tool but be careful because they can be pretty harsh and
negative
it's kind of scaring number three is product on
like I said it's probably the best in terms of getting your users because
everyone who gets a problem newsletters or just really interested in new
products of all times
but nowadays i think pretty sure there's a waiting list and it can be a little
bit difficult to get on there so the better way to get on there is to build a
really good product and finally whatever your customers
so like I said the first thing you have to do is forget our customer is and then
the next places to put it there so if your customer is not a person like
pastas developers and spend all day online
I can have to go offline and find them and and tell them about your business
them you know
so conventions their place of business giving calls emails showing up in person
all of these things sounds scary but they're totally valid method for getting
customers before getting customers like i said so when one side launches write
it down product on and hacker news or not and i read it and you know it did
pretty well it had a couple few days where i had a few hundred signups I
think
and after that just growth
basically all the way down to zero you know maybe one user a day so I realized
that I couldn't be continually launching it on all these sites so i had to come
up with a more solid way of your customer base so i put I i did so by
focusing on a few things and some of these are gonna be a little
counterintuitive because I think a lot of the time when you hear about Rose
hacking and growing company
you sort of get the start up mentality which is growing as fast as possible you
know you want to do the hockey stick right and I didn't do that would you sir
we grew slowly but settling so the first thing we did was we focus on SEO and
those who don't know
SEO is search engine optimization making yourself throw up higher on google
essentially and I knew nothing about SEO
I knew that it was a thing but i had no idea how to do it
so first thing I did was google a lot of stuff about how to get better at SEO and
i've included a lot of the more useful links that i found in the show notes but
essentially the number one thing is you want to focus on keywords and get your
site to be really really fast and so I mean optimization is great and that's a
whole topic into itself so i don't really talk about it but you want to
make your site
super super pass and then secondly sort of like coming up with an idea and
coming up with a customer bases you want to focus on you want to determine what
search results you want to show up in so what are your keywords that you're going
after you
and a great way to do this is to use the Google Adwords Keyword tool and
essentially what this does is allows you typically use it to purchase google
adwords will show up for certain search results but it does two things that are
really important that are relevant SEL is it will tell you the the competition
of that combination of keywords and it will tell you the search frequencies
will tell you how many times a month
those particular combinations of words to search so ideally what you want is a
search term that is as low competition and high search for equal chances are
you're not gonna be able to find this because they're very very rare
what's better than in this case
like I said with the whole idea of starting small if you want to find
something that has both the low competition and low search frequency so
if it's only a few people are searching for that amount
that's okay because those people probably desperately need what you're
offering another thing to focus on is the concept of long tail keywords and
what this is is like very long and complex and specific strings of
characters for you know very detailed search results they're very specific
so a great example for juicer was how to embed a social media feeds into Shopify
site
you know there's probably 20 people a month and search for that but those 20
people desperately want we're offering
so we sort of come up with a couple combinations of things like that where
you know various different sites and just sort of think about what I would
search if I was a different customer type and so my one really genius thought
when it comes to SEO and the thing I think that made as you're working more
for us than anything else was bothering a free plan and I didn't really mention
it before it was a juicer is SAS business software as a service so
essentially what that means is that our customers are paying customers pay for
monthly pay a monthly fee and I get to use our product and definitely as long
as they keep going
but there's also a freak here so it's got more limited functionality that
allows you to sign up and test it out and it's free forever
so a lot of people who can't afford to spend anything on this service but they
still want to social media feed on their site and we allow them to do so
the one caveat is that it has juicer bringing it and so this was sort of my
my genius sort of double edged SEO insight is that not only are is painted
sign up for a paid account incentive to get rid of the juicer bringing out of
your feed
black badges are bringing also is links on other people sites that are linking
back to juicer and each one of those increases our SEO geez
so obviously that's not going to work for every type of business but I think
there's something like that or just about every product that some sort of
hacker or you know sort of light bulb inside that everyone can have the next
thing I focus on was content marketing and content marketing is essentially
writing blog posts and essentially this is just a subset of SEO and so like I
said a great blog post that ended up writing was how to add a juicer social
media feed to amplify site you'll notice that the titles is how to add a juicer
social media
so it turns out one of the keywords we went after with social media feed or so
visit this is great for two reasons one because it increases your SEO Jews as
well you know anyone who searches for Shopify social media is going to find us
and two is because it actually teaches something to users and it's useful to
someone who finds it will then actually be able to follow along
do you say and then the problem solved and they're happy and you always want to
make your customers happy
the one sort of my one sort of genius in sight as well with with content
marketing was as juicer
I knew but virtually nothing about the social media marketing so and we were a
company that that's what we do is be provided a tool for social media
marketing so it's a little embarrassing to have a twitter account but had 50
followers and maybe even less
so I sort of wrote a series of blog posts about our journey into social
media marketing and sort of like what I learned what I tried and what worked and
dip downward and it ended up working out really well because people who are
searching for like how do i grow my Twitter followers then come to us they
would learn something about that and then as well
oh by the way juicer will help you with this - so it's sort of like was like it
you know another sort of two pronged approach to growing our customer base
the next thing we did was we built a plug-in or an add-on and the first
plug-in that we build was for wordpress and so WordPress is for those who don't
know you probably all know like a crappy PHP forum or blog framework three sites
so i had to write PHP code which was nightmarish but it was ended up being
great because for a few reasons because one we could submit it to the wordpress
plug-in directory immediately and the WordPress plug-in directory is super
easy to optimize the search you essentially just put a list of all the
words you want to show up for and then you just immediately show up on can
search for those so anyone who is using wordpress oftentimes when the install
plugin they don't go to Google they just go directly to the WordPress directory
in the circle mayor so basically overnight we were showing up at the top
of the WordPress plug-in directory
which is great and you know it's really great because WordPress anyone who's
looking in the WordPress plug-in directory is building a site so those
you're also customers right there like have people who need to address to the
site but they're building right now
and the last thing I recommend and I didn't have to do this because my
business is online only
but you want to hit the street if your customers aren't online
you're gonna have to go talk to him in your life you talking you're talking to
our customers step number five is that your customer so you build the product
you've launched it and you taking some steps towards getting growing your user
base
so when when we were surgeries are obviously didn't have very many
customers we have a few people that signed up here and there but we almost
immediately after launch put up a contact page and email address on the
site and I don't think for the first couple weeks
anyone contacted is really but I can sort of observe how people were using
the site you know people don't want my family and friends and just signed up to
be nice and and I would reach out and talk to them and see you know what they
thought about it
the sort of email them and see if they have any thoughts one way or another
about user
most people going to respond to me but if you did and if you give me a really
great insights and so during the same time you know people start slowly
trickling in the SEO SEO takes a long time to take it back dogs that have
negative three or four months before we probably got any users from google
search and we got a few more from WordPress because that happened quite a
bit more quickly but still it got to the point where you know once a week and get
an email from a customer and all of a sudden twice a week I was getting an
email from a customer and then once a day i was getting email from customer
and so
I have a lot of customer service myself so slowly but surely people started
emailing as more and more and more and it got to the point where i was getting
a bunch of emails a day and I think it's really important especially as the
person who built the site that you handle the customer service yourself
yourself don't have anyone else to do it for you and this is for a few reasons
one because you really sort of keep your finger on the pulse of your site you'll
know what your customers are using it for what problems they are having what
will definitely tell you about any bugs they have and you'll really get an idea
of what they wish the product could do because they'll ask you hey can I gonna
do this so i think when you're doing customer service
it's really important at first to be unscalable so customers will ask you hey
can you recite do this or hey I wish it did this and that what i recommend doing
it for release in verse is do all of it so they say hey can u district
yep or not the second but now it does and so this will teach you
sort of like a big pain that you're your customers have to go through so so you
know you do it as manual as possible i want to recommend doing this like
building out feature immediately so do whatever it is your customers ask you to
do and do it Superman and you want to do is for a few reasons one because you
want to waste your time building something that only one customer needs
and two because it's not one customer needs you get several people asked me to
do it and a bunch of people ask you to do it and eventually you'll get really
sick of doing it and so this will give you a really good idea of what is your
customers have to go through every time they're doing whatever task you with
your product in and and do it that means it's a really good feature idea for your
product and you should probably add it to your site if at the very least so you
don't have to do it anymore yourself
but this
if you get really sick of having to do something that customers that need to do
that's a really good sign that it should be in your product and so this is that's
where improving your product comes from so you do customer service enough and
you'll get a really good idea of what it is your product used to have a set
number 6 is to repeat step 5
you guys remember that customer service to your customers
so hopefully what's happening here is that people will sign up and they'll say
hey we should do this or hey what is going to do this and we'll keep asking
you the same thing over and over and you'll get really sick of it and then
you build it and then people stop asking that but then they'll start asking about
something else
hey we should do this I was into that and just keep doing this over and over
again and so eventually you'll reach a point with which is known as product
market fit which is knowing that whatever it is you're building has found
its niche in the greater economic realm
so you're going to have to keep repeating this for basically forever
them juicer is not about two years ago and I'm still repeating step 5
every day step number seven
ok number seven if the first you don't succeed try try again
so juicer is definitely not the first product ever built that place it
somewhere around the seven sort of full product of built on my own and it's
definitely the first one I would consider to be successful by any sense
of the word
don't get hardened disheartened if what you tried doesn't work with something
else and try again
and so those are the sort of main first seven steps i think that it takes to
build a product and I kind of took a really wide brush strokes there I think
but i just got a few more tips here for you
and so the first one is great business you every time I know I kind of gave a
bad rap to work a full-time job earlier but I definitely don't recommend putting
your job immediately and going out of starting a business and said create a
business in free time and this is really easy too young and single and don't have
kids but if you are a highly recommend if you are all those things are highly
recommend building every time
number two is to grow slow so there's no rush
and there's a few reasons to go slow in one is it will become allow you to
become the master of your problem domain so if you're like me you started social
media aggregation business and you don't know anything about social media or
recreation or anything of that nature and by growing so i was able to really
sort of understand how what is our customers are doing and why they want
this service number two is it will allow you to really get to know your customers
and the more you to know your customers
provided you're a good person and you probably are the more customers will
like you
and the more your customers like you the more people will sign up for your
service
the 30 another reason to go slow and allow you to scale your infrastructure
without having to hire people and so the nice thing about growing slow is that
you can do it yourself
and so this means you don't have to raise money you know be a real startup
which means the state's the lower means less stressful and it means that no one
is your boss still which to me is kind of the whole point
so the really nice thing about being developers and we're all developers here
is that what the main reason that you have to raise money as a higher people
generally the first person you hire a developer you don't have to do that
so besides that you don't have to worry about you actually wasting your time
raising money talking to investors keeping them updated about what it is
you're working on
you could spend all of your time working on your product no tip is to find a
partner
so this is for a few reasons i generally recommended non technical part of the
partner but the technical partner is great as well and they let you do a few
things
so there's someone to bounce ideas off of which is really great just to have
someone to talk about it was my girlfriend gets really sick of me
talking about you all the time
it's someone to motivate you when you're not feeling motivated so i know that
there were certain points during juicer especially right after we launched where
if I didn't have a partner I probably would have just given out because it
seemed like an insurmountable problem to get customers but I had a partner and I
didn't want to let him down so i get working on it and paid off
and finally the greatest part about having a partner is it someone to do all
the things you don't want to do so this means like getting a bank account and
setting up a proper corporate structure are talking to lawyers or really doing
anything you want to do which is great so juicing today
juice has been around for almost two years
when I first started we had one customer and one paying customers we had a
hundred percent conversion rate and it's it's gone down quite a bit since then
but now we have about 17 thousand customers and ten percent of them are
paying and it's by far the best paying job I've ever had
i work an average of one of four days on sorry will
i work an average of one of four hours on a juicer per day depending on how
much I'm building versus how much customer service i'm doing it
any questions so the question is do we doing currently testing and the answer
is yes we did when we first started we had at one price in mind which was then
sold price which is ten dollars a month and actually the way it works is a
little bit different so when we first launched
you got a 30 day trial and there was one like okay account was ten dollars a
month and i think it was like sort of unlimited everything you want updates
every 10 minutes and nobody signed up and so one of the first things we did
was actually introduced or like tiered pricing like having different pricing
models and then offering the free version bring forever version and that
was sort of like a combination of my SEO plan but also people like try to discern
extent so we sort of have like a real cheap version and I'm like a more
expensive that was really sort of had to build more functionality to support the
more expensive version
well it's a good question the best timing device to find a bc but we
haven't found any bc with juicer
well people have actually reached out but we've specifically told them we're
not raising money at least at this moment
so that's a good question i had i think anytime if you need money anytime is a
good time to find a bc sooner rather than later
sometimes
but i would generally say you want to at least validate your product first so you
want to have built the MVP and gotten some users sign up and I do we are
showing up into the right bro
but unfortunately I'm not a master of raising pc capital so i can tell you the
best overall ok so the question is two parts one is like what makes juicer
what made me think I was gonna be some more successful or what makes you seem
more successful mile price and then what
when did I know to give up my old products and so the first thing I'll say
is that juicer is the first product I've ever built
we're from the get-go I sort of had an idea of how to monetize it everything
else I've always built this build a cool thing and then people will sign up for
and then I'll be rich but I never really had any plans
it was the first one that was like an actual business from the beginning and
then number two is how did I know when to give up my other products and i'll
say that I don't know
I didn't even really consciously give up on that might just sort of stop thinking
about their slowly stop thinking about them and then of course the less
attention
the less they did I think general you can tell but for me it was sort of like
the in the I kind of spot at least 14 started doing this sort of thing that
but all I had to do was build it and they will come sort of thing but that's
going and building it is the easiest part and giving customers is the hard
part
well as a bunch of our parts but that's one of the hard
and so I think a lot of times i would just sort of build it launched it get
out there and be like my job is done just let that thing grow and obviously
that's not the way to approach it but I think you can tell
and if it's if it's certainly if you're not thinking about anymore that's fine
but i don't know i could tell you the ideal
yeah so the question is since i don't have a BS degree and I don't work with
any other programmers
what do i do when i need help or have questions or when I need to talk to
someone about these things
well I I I definitely think that giving it full time job
previously to this as a software engineer was one of my biggest role like
learning experiences really accelerated what I knew and you know through those
jobs I've had I have various friends that I can talk to and i have
surprisingly a lot of friends who sort of done similar things to me and they
don't really work full-time anymore and have started their own businesses so
we'll get together and talk a lot of that sort of thing
you know I use that work with a lot even now my questions about how something
should be done because that I don't definitely don't know how to do
everything
a lot of googling I also my girlfriend's developers so i can always plug her
about things i think i'll get somewhere
yeah