Make mod 1 easier than it otherwise would be: a guide
This guide will make Turing's mod 1 much easier than it otherwise would be.
note: please see the updated version of this guide; if you continue reading, you'll have a far inferior experience than if you head over here: https://josh.works/turing-backend-prep-01-intro
We'll do this by working on, (and completing) a few dozen small Ruby exercises.
You might be thinking:
Josh. This already sounds like a lot of work. I just finished my prework, and I know Turing's gonna be brutal. Why should I do all of this optional work, instead of enjoying my last few days of freedom?
Good question. The answer is a digression into the topic of tortured analogies involving screw bits, how to learn hard things, and why you should do drills.
How to learn hard things
If I handed you a
spax screw, and told you I'd pay you $1000 to screw it into a piece of wood, and then handed you a Phillips screw driver, what would you do?
Spax screws look like this:
A philips screw bit looks like this:
Philips bits are for driving philips screws, which look like this:
So, can you drive a spax screw with a philips bit?
You could try really hard, use great effort, and end up damaging both the screw driver bit and the screw, and probably barely get a single screw in. I bet, though, that you could get a single screw partially embedded in the wood.
What if I were to pay you $1000 per screw you could drive into the wood?
Now you can't rely on just herculean effort, sleepless nights, and tenacity.
you have to have the right tools.
For $1000 per screw, you could afford to buy the correct bit, and it would let you effortlessly drive the screws.
I'd argue it would be irresponsible to not get the right tools.
It could be considered irresponsible to not acquire the right kinds of tools for doing imporant things. (like becoming a software developer.)
Obviously, you need the right physical tools. A laptop, functioning screen, etc. But to learn hard things, you need the right mental tools.
How to learn hard things
To learn hard things, you need the right mental tools.
I strongly recommend buying or renting a copy of A Mind for Numbers: How to Excel at Math and Science (Even If You Flunked Algebra).
Do that, but then read these two summaries of the book:
- Faster to Master: Book Summary: “A Mind For Numbers”, Barbara Oakley
- Karl Booklover: A mind for numbers — Summary
A Mind for Numbers talks about how to learn hard things. The author talks about mental models, "chunking" information to free up working memory, practice, drills, repetition, staying the right amount out of your comfort zone, doing hard things, avoiding distraction, procrastination, etc.
Everything in that book is relevant to the rest of your career in software. Please read the book.
Now, I know most of you will not read the book, despite my strong suggestion and humble request that you do so. That's fine, I guess.
If you're not going to read the book, you don't get to question my methodology for the rest of this guide.
To learn hard things, you need to build mental models of the hard thing, and you need practice and repetition.
Most of the world is on board with the value of "drilling" important things. Fire drills, drills for sports teams, drilling to practice something you'll be tested on - all of these are ways to make sure not only that you know how to do the right thing, but you can't get it wrong.
So, working through these drills will move you in the same direction. You'll not just build a single class (in the mythical creatures), but you'll eventually do it so many times you can't help but get it right every time.
This will make the rest of your time at Turing go much, much better. It could help save you from repeating a module (six weeks saved, plus a few thousand dollars), and will serve you for the rest of your career as a developer. (Over a decade or two, we're talking about many hundreds of thousands of dollars.)
But don't take my word for it.
Feedback from Turing students
As a result of doing all these drills:
I definitely feel over prepared in some aspects, but I'm trying to use it to help everyone get to the same levels of understanding
It has been amazing and I feel like I learned so much from mythical_creatures...
The mythical_creatures felt like it like brought everything together and how it works (on a kindergarten level) but made it all feel...real-ish in a way, and that was huge.
i swear to god, knowing what pry was and having done mythical creatures helped me so much here!
From those who did not do the drills:
I wish I’d done mythical creatures and more before. I really struggled in mod 1
Why are drills effective?
Lots of reasons. If you want to get into the nitty gritty, know that they line up closely with the principles of Deliberate Practice which is... how anyone can learn anything.
Finally, to make progress in drills, you'll have to get good at examining your own assumptions about what your code is doing, while getting deep into your IRB or Pry prompt.
- getting the right files (start here)
- video walk-through of the
- video walk-through of the first mythical creature (
- video walk-through of another mythical creature (
- troubleshooting various errors you might see
A warning - the hours ahead that you spend on this will be chock full of error messages. Embrace googling error messages! When in doubt, google it, even if it's meaningless to you! Somewhere on the internet exists hints and clues about what to do.
This skill set (googling for hints, using those hints to improve your googling, testing those assumptions, not giving up, etc) is known as technical sophistication.
Every time you encounter something unfamiliar, and google your way to an understanding and/or solution, you're building technical sophistication. This is a very good thing.
In technology, a similar skill (or, more accurately, set of skills) exists in the form of technical sophistication. In addition to “hard skills” like familiarity with text editors and the Unix command line, technical sophistication includes “soft skills” like looking for promising menu items and knowing the kinds of search terms to drop into Google... along with an attitude of doing what it takes to make the machine do our bidding.
These soft skills, and this attitude, are hard to teach directly, so as you progress through this and subsequent Learn Enough tutorials you should always be on the lookout for opportunities to increase your technical sophistication... Over time, the cumulative effect will be that you’ll have the seemingly magical ability to do everything in every program.
Getting the right files
Here's all that you'll need to run drills for the next few weeks:
we're going to work through getting set up on this as incrementally as possible.
1. clone the repository to your machine
That might be all greek to you. no worries! Open this URL: https://github.com/turingschool/ruby-exercises
click the "clone or download" button:
it'll look like either:
It doesn't matter which one you use. You can read more on the difference between HTTPS and SSH URLs here
Now, in your terminal, clone down the repo. We'll use the
git clone command:
$ git clone https://github.com/turingschool/ruby-exercises.git
or, if you used the SSH url:
$ git clone email@example.com:turingschool/ruby-exercises.git
2. Find the first exercise
You should be able to see the cloned directory on your machine. If you run
ls in your terminal, you should see an entry for
cd into that directory:
Lets start with heading into
cd data-types ls # i usually run `ls` just to see what is in each level of a directory. I'm a curious person. cd strings ls
When you call
ls the last time, you should see
strings.rb. If so, you made it!
cd up a level or two, and look around again. (To change directories up, you can do
3. open everything in Atom
now we'll open everything in Atom:
$ atom .
README file, and read it.
(if you have problems opening atom, read below
4. run the file in your terminal. Resolve any error messages
run the file, in your editor, with:
$ ruby strings.rb
You might get an error like this. (I've highlighted the relevant pieces of the error. The first highlight shows where in the file we ran into the problem, and it's line 3 of the
The second highlight says "cannot load the thing required in line 3".
Now, take a look at line three of
that's a gem we need.
If you don't get this error, great! You already have
pry on your machine, and you can skip the next section.
What the heck is a ruby gem
A "gem" is just a little bundle of code that interacts with Ruby.
And, since we need to install the
pry gem, we can look it up and see what it does. I googled
ruby gem pry and clicked the first result, which brought me to: https://github.com/pry/pry
Feel free to read the docs, and get a feel for what Pry can do for you.
Anyway, install the Pry gem with:
$ gem install pry
If you want to see all of the gems installed on your computer already, you can run:
You can read more about the
gem command here
See the references to
minitest at the top of the file?
This are "modules" of the
I strongly recommend "pausing" this guide and reading (and re-reading, and write all the code from all the examples in) this excellent guide: https://launchschool.com/blog/assert-yourself-an-introduction-to-minitest
I'll state that again. Read and study the minitest guide. It is fantastic and will set you up for success for the rest of Turing:
Did you read the launchschool post? Great! Then most of what is in this file should look a lot more readable to you.
As a quick test, answer the following questions:
- What is minitest?
- what is a Domain-Specific Language (DSL)?
- What does
assert_equalmean? How many arguments does it expect?
assert_equal true, "true"pass?
- How do you "run" a test file?
- is a "failing" test a bad thing?
- does minitest run all the tests in order?
- Find a list of minitest assertions (google it!). What's a cool one you found?
Awesome. If you can answer all of those questions, you've got your head wrapped around Minitest. Onward!
5. run the file again, get a bunch of
SSSSSSSSS printed out
this is the error code, then resolving it by installing the pry gem, and then the successful results of running the file:
Wahoo! If you see a long string of
SSSSSSSSS, you're doing great.
Here's what minitest results mean:
Smeans "skip", and it means we "skipped" the test. (see all the words inside each method, that say "skip"? that's how we skip that test.)
Emeans "error". the test couldn't run for some reason.
Fmeans "failure". the test ran, but didn't pass.
.means "success". The test ran, and passed.
So, lets make the first test pass.
6. Video Walkthrough of
Here's a video walkthrough of making the tests pass. Might be useful!
Once you get the hang of it, try pausing the video and keep going on your own. Then unpause the video, compare the results, repeat. (But please do watch the video, at least this little section on using Pry from inside your tests: https://www.youtube.com/watch?v=BKqo2w0W7S0&t=654s)
Go ahead and finish this file, and then the other files in the same directory. (hashes, arrays, etc.)
Once you've finished the above exercises... you may want to take a spin at the imfamous mythical creatures! Dun Dun Dun....
They make use of "object oriented" programming. All that means is you will define an object (like a
Person object) and create instances of that object that have certain behaviors and methods of interaction.
This is a lot to wrap your head around, and "object oriented programming" is a topic that fills dozens of books, hundreds of conference talks, and you'll spend the rest of your life building a better understanding of. So don't feel any rush to grasp it all in the next ten minutes.
Start with this guide: https://launchschool.com/books/oo_ruby/read/the_object_model
Read it carefully, but don't worry that it all won't make sense. Take notes, run the code examples. Take an hour on it. When you've gone through it once, tackle the first mythical creature.
It can be tricky getting set up, so here's another video of the very first mythical creature:
A quick aside - as you work through these exercises, and all of the exercises to come, you'll perhaps notice a constant tension between "results" vs. "process". Here's what I mean by this, explained in a conversation with a Turing student, working through this exact guide:
[...] In other words, there is more than one way to achieve the result, so do I focus on process or product? I am not expecting there to be a single “right” answer, but I am curious as to how Turing is going to evaluate us. Are the steps used more important than the outcome?
I responded with:
Your intuition is leading you well - the steps and the outcome, are important.
I'd recommend de-emphasizing the Turing evaluations in your mind, though, and just focusing on building the right kind of skills that will serve you well for the rest of your career as a developer. And, from that lens, there will always be tension between
the best I know how to do right now and the best that can be done, ever
Obviously, as you grow your skill-set as a developer, you would be able to go back and improve prior bits of code you've written. It's rare to crank out a "perfect" project, no matter how small.
So, optimize for learning, which basically means... when you find something that works, use it, but next time you come across a similar kind of challenge, you might use something slightly different. I don't know if any of this makes sense. It basically means
don't sweat not getting exposed to every single ruby method, but be open to using new ones as situations arise, and you get more comfortable with the ones you know.
Or, in summary:
There may be multiple ways to achieve the required outcome; use what you now know; be on the lookout for other methods that achieve the same result.
Feel free to rely heavily on my solution here in the video, but when you're done making it pass the first time, you must delete all the code (and the file containing the code), and do the exercise a second time, from scratch.
If you don't, you will get maybe 10% of the learning out of this exercise that you should. I made this video not to give you the solution, but to help you get the shape of running the drills. Now that you know the shape (from the video) you can do the drills, but you must re-build
unicorn.rb, if you made it pass while watching my guide.
Once you've re-built your own
Unicorn class, re-read the Object-Oriented guide: https://launchschool.com/books/oo_ruby/read/the_object_model
Much more of it will make sense to you this time.
We're doing another Mythical Creature - this time,
dragon.rb. I'll get a bit deeper into using Pry, as well as opening with a very minor (but very important!) Terminal modification.
- Setting new tabs/windows in Terminal to open from current directory. (more on this)
- Atom split panes (more)
- Atom Autosave package: It's in your editor by default. here's how to turn it on
- Atom package that shows current indentation: (vertical white lines) indent-guide-improved
- Atom package that highlights beginning/end of method: ruby-block
- Atom package that highlightes all instances of selected text: highlight-selected
- discussion about how to run just a single test in minitest: https://stackoverflow.com/a/9310490/3210178
- how to run just a single test at a time from the command line
selfinside of pry, to see the current object under test.
hobbit mythical creature is a bit tricky. We have to start doing things with methods, without necessarily returning anything. Then we have to "interrogate" the object under test to see what has changed, and if some things have changed in a certain way, we do one thing, if not, another.
IF YOU HAVE QUESTIONS! Please leave a comment in this gist. I'll make sure to integrate answers to your questions into this guide.
As you run into problems (and others) let me know. I'd like to collect a broad swath of the errors folks run into, and the solutions, so they don't get too caught up.
Traceback... cannot load such file -- pry
This seems like an intimidating error message at first.
It's not. The error just says:
Dear user, you've asked me to import code to run these tests, but I cannot find the code you require.
The code I was looking for (and cannot find) is called
Pry is an amazing tool. You'll soon come to love it. In the mean time, just install it. It's a ruby "gem" so you use the
gem install <gem_name> command.
In your terminal, run
gem install pry and then run the tests again.
Cannot open atom from the terminal
Install Atom Shell Commands
Atom makes it super easy to do this:
FSPathMakeRef and a bunch of other stuff
Here's an error one student saw:
FSPathMakeRef(/Applications/Atom.app) failed with error -36.
Googling around lead here: https://github.com/atom/atom/issues/5222
One possible cause was the user's machine had two instances of
Atom.app on it. (In this case, one was in the
Downloads folder, the other in
Applications. Delete one of them, try again.
- http://tutorials.jumpstartlab.com/academy/workshops/objects_and_methods.html (companion piece to some of the above guides)
- another one of my gists: terminal command summaries, tab-complete git branches, and a better terminal prompt (with video)