Backend Mod 1 Pre-work Repository

This repository will walk you through the Mod 1 Pre-work for the Backend program at Turing.

Each day has a folder containing a README.md file with instructions for the section, exercises, and questions. Please complete all the exercises and questions, as well as lessons listed in the section's README.

Pre-work Index

What to Expect

Through completing this pre-work, you can expect to get practice re-enforcing what you learned/are learning in Mod 0, learn more technical content, and deeply reflect on your mindsets and habits and start thinking about which of those mindsets and habits will help you learn to code, and which of those you may need to change.

We will remind you of the best practices that follow from time-to-time, but to ground yourself in the work ahead, read them carefully.

Best Practices: Learning to Write Code

If you are stuck for longer than 30 minutes, know that it is always ok to ask for help! The process of becoming a software developer is difficult, and learning to code is hard. At some point, everyone struggles. Struggle is a normal, healthy part of the learning process - don't give up if you hit a hard spot. If you consistently practice every day and don't take shortcuts, you will be on the path to learning how to code. When you reach out for help, challenge yourself to ask clear questions and use technical vocabulary. Speaking accurately about code is a great way to help lock in technical understanding. Use this guide to learn the optimal way to ask for help when you get stuck!

Process over Product. When asking for help, do your best to seek understanding rather than the answer or the solution. Even if your helper gets you a solution that works, make sure to spend time on why it works, rather than just accepting the solution and moving on.

Type every line of code. One of the best things you can do to set yourself for success is to make sure you type out all the code examples you see in the readings and exercises in this pre-work, do not copy and paste. The more hands-on-keyboard practice you can give yourself, the better. Copying and pasting won't help you solidify these concepts, manually typing all the code in will. This also applies to auto complete features in popular text editors. They are helpful, no doubt, but doing things the hard way at the beginning is a great way to hone your workflow later on.

Details matter. Pay close attention to small details in syntax, spacing, and language. The most detailed oriented you are as you're working, the more reliable and well-crafted your code will be. In programming, being detail oriented helps cut down on buggy code and difficult to use systems. It can also help you notice differences in your code, enabling you to identify typos and mistakes more quickly.

Environment

Follow this guide step-by-step to make sure you have everything you need.

Before proceeding, if you have not already, complete the mod-0 environment setup instructions to install Atom, xcode-select, Homebrew, git, and Chrome.

Next We will cover the following:

First, let's get a Ruby version management tool on our machines.

Set up Ruby Environment Manager: rbenv

Installation

NOTE: If you have any issues with the rbenv setup, please reach out in slack in your cohort channel and we will address your issues at a later date! Your system version of ruby will work fine for your Prework exercises!

-->

Similar to Homebrew, rbenv provides a script to get everything installed. Open a terminal with Spotlight search (Command + Space) and enter these commands:

$ brew update

Wait a few moments for brew to check its current version and make sure it is ready to be used.

$ brew install rbenv

Wait again, as brew installs rbenv.

$ rbenv init

The output from your terminal should be something similar to:

$ rbenv init
.
.
.
# Load rbenv automatically by appending
# the following to ~/.zshrc:

eval "$(rbenv init -)"

This output is telling you that you will need to add the above line (beginning with eval) to your "bash profile".

To do this, in your terminal, enter:

$ atom ~/.zshrc

This command will open up your ZSH Runtime Configuration file in Atom so you can edit it. Copy the line eval "$(rbenv init -)" and paste it at the END of the .zshrc file, and save it.

Check to see if you did this step correctly by switching back to your terminal and typing cat ~/.zshrc. You should see eval "$(rbenv init -)" at the bottom of the output.

After, close your terminal and reopen it. This is a very important step since the bash profile is loaded each time a new terminal window is opened.

Now, check to make sure rbenv was installed properly. In your terminal, type:

$ rbenv versions

It should give you a version number rather than an error message.

More information about rbenv can be found here.

Use rbenv to install a certain version of Ruby

Now that we have rbenv installed, we're going to use it to install a specific version of Ruby: Ruby 2.7.2. This is the version we will use in the Backend Program.

If you need another version it'll be the same procedure, just replace 2.7.2 in the instructions with whichever version you want.

Install it with:

$ rbenv install 2.7.2

It will take a while to finish installing, and print a lot of text to your terminal.

When it's all finished, type:

$ rbenv versions

and you should now see 2.7.2 listed.

Be careful, there are two different rbenv commands, version and versions. The first shows you your current ruby version. The second shows all installed versions.

Switch to your newly installed version with

$ rbenv local 2.7.2

Now enter:

$ ruby -v

This shows us what version of Ruby we are running. You should see something like:

ruby 2.7.2p105 (2018-10-18 revision 65156) [x86_64-darwin17]

You can ignore everything after the p in 2.7.2p105- the first bit shows us we are running Ruby 2.7.2, which is what we want to verify. If you got something different than 2.7.2, such as 2.4.1, go back through the Rbenv installation, make sure you have you successfully edited your bash_profile, restart your terminal, and try again.

Setting the Default Version

You can tell rbenv which Ruby version you want to use by default. Let's do that with terminal command:

$ rbenv global 2.7.2

Now, let's make your terminal aware of this update with command:

$ rbenv rehash