1.13 Ruby Conclusions
That’s it for our crash course! Congratulations, you’re ready to begin using Ruby in your web applications to develop the backend code.
1.13.1 Our Technical Reference vs. Google-Fu
Much of what we covered in the previous sections is collected in the Ruby technical reference. This is intended to be a quick reference of the classes and methods, and includes many things yet to come in the course. Nevertheless, it’s very handy to keep open.
At this point we have all the building blocks:
- Expressions: object.method(argument) # => returns a value
- Variables to save the results of expressions.
- Conditionals (If statements).
- Loops.
That’s all we need. We can build anything with these, using just some careful thought and what you can find in these chapters.
We are inventors
When you signed up to learn how to program, you signed up to become an inventor.
Software developers, by definitions, tackle unsolved problems. There aren’t predefined solutions to look up and apply. Otherwise, we’d just buy something off the shelf and be software users. (Much cheaper, if a solution to your problem already exists.)
When faced with a task, your first instinct should be: “How can I solve this puzzle with the tools I have?”
Your first instinct shouldn’t be: “Let me Google for a solution to this problem.” Developers do a lot of that, of course, but only after we’ve tried to solve it with what we already have.
“Google-Fu” is a hugely important skill to practice in software development, but in this course you should resist Googling. The answers you find are not suitable for beginners; they will more than likely slow you down. For example, many of those posts will use different syntax than we’ve seen up until now, and that will be confusing!
Any assigned task will be achievable using the classes, methods, and keywords introduced in the Ruby Chapters. Your job is to invent a combination of them that gets the job done.
1.13.2 Ruby Gym
Before we go on, let’s stop, take a breath, and try to put what we’ve learned so far to good use. The idea with the following exercises is to use the building blocks from the previous sections to write some small programs. These are longer projects than the exercises we’ve seen so far, and they may require a few different tools to complete; so keep the chapter sections open for reference and scan through them for things that may help when you get stuck. All the tools are there.
Well, almost all the tools! There’s a few more collected in the next section that you may find useful for some of the exercises. Look through them when you get stuck.
There are likely a few ways to solve an exercise. Just get the code to pass all of the rails grade
tests and you are good to move on. Remember, we are inventors; don’t rely on Google-Fu.
Please follow the instructions below to enter the Ruby Gym for some weight training 🏋️!
Open the GitPod Ruby Gym project and complete the exercises:
LTI{Load assignment}(https://github.com/bpurinton-appdev/ruby-gym/tree/bp-edits)[MV4dKHMwdAFhfRn752YW3TAY]{KBpPhe42o6wDRi35rWagKY4F}(20)[ruby_gym_project]
For a GitPod refresher, see here.
The suggested order (feel free to go in whatever order you’d like) is:
think_fast.rb
two_fer.rb
dice_roll.rb
character_types.rb
accumulate.rb
secret_encoder.rb
secret_decoder.rb
leap_year.rb
raindrops.rb
count_the.rb
sum_odd_integers.rb
black_jack.rb
Optional stretch goal
If you finished the previous exercises, and you want some more, feel free to also work on these optional exercises found in the Ruby Gym:
anagram.rb
isogram.rb
hamming.rb
darts.rb
phrase.rb
Addendum: Optional Ruby Practice
If this is your first time programming, then it’s a lot of new concepts to absorb! Sometimes hearing the same concepts in different words helps. Here are some other optional resources you can go through at your leisure if you’d like more Ruby practice:
- Treehouse’s Ruby Basics
Other than the introduction to Ruby that I’ve written specifically for our purposes, Treehouse’s is the one I like best.
If you would like even more practice before we get to our own introduction to Ruby, then there’s also:
- CodeCademy’s Learn Ruby track, up to and including Part 4 (Arrays and Hashes). (After Part 4, they touch on quite a few concepts that we won’t use much during AppDev, but are useful in the long run if you continue with Ruby.)
Both Treehouse and CodeCademy have an in-browser programming environment, so it’s easy to just start learning right away (no installing of things on your laptop required).
However, be warned that both Treehouse and CodeCademy mention some language features of Ruby that I deliberately cut out in order to keep our learning load as slim as possible. It’s not necessarily bad to see them, but we won’t be using them in class.