`. You can assign the return value of the expression to a variable.
266 |
267 | ```ruby
268 | age = 18
269 | response = age < 17 ? "You still have your entire life ahead of you" : "You're all grown up"
270 | puts response #=> "You're all grown up"
271 | ```
272 |
273 | Here, because the expression evaluated to false it was the code after the `:` that was assigned to the variable `response`.
274 |
275 | To write this as an if; else statement would be much more verbose
276 |
277 | ```ruby
278 | age = 18
279 | if age < 17
280 | response = "You still have your entire life ahead of you"
281 | else
282 | response = "You're all grown up"
283 | end
284 | puts response
285 | ```
286 |
287 | However, if your conditional statements are complicated, then using an if; else statement would probably make more sense. Remember, **above all else your code needs to be readable and understandable by other people**, especially in the development stage. You can always optimize your code for efficiency once it's finished and you're moving to a production environment where speed matters.
288 |
289 |
290 |
291 | ## Further Reading
292 | *This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something*
293 |
294 | * Launch School's [chapter on flow control](https://launchschool.com/books/ruby/read/flow_control#conditionals) is a good learning resource.
295 |
--------------------------------------------------------------------------------
/new_course/1_programming_fundementals/debugging.md:
--------------------------------------------------------------------------------
1 | # Debugging
2 | A brief summary about what this lesson is about and why the topics or concepts it covers are important.
3 |
4 | ## Learning Outcomes
5 | *Look through these now and then use them to test yourself after doing the assignment*
6 |
7 | what the student is expected to know or be able to do by the end of this lesson
8 |
9 | * Learning outcome 1
10 | * Learning outcome 2
11 | * Learning outcome 3
12 |
13 | ## Reading the stack trace
14 | * what is the stack trace?
15 | - the execution of your code
16 |
17 | * how to read it
18 | - start at the top to find the error
19 | - it displays the line number
20 | - tells you the type of error it encountered
21 |
22 | * include an example stack trace of an error
23 |
24 | ## Puts Debugging
25 | * what is puts debugging
26 | * how to do it - small example
27 |
28 | ## Using PRY
29 | * What is pry and what does it allow you to do
30 | * link to an external tutorial
31 |
32 | ## Exercises
33 | Exercises in an external repo
34 |
35 | ### Additional Resources
36 | *This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something*
37 |
38 | Link to no more than three additional resources to avoid this section becoming too cluttered.
39 |
--------------------------------------------------------------------------------
/new_course/1_programming_fundementals/hashes.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 | Now that you know a bit about arrays, it's time to get into the array's supercharged cousin: **the hash**. The short definition is: Ruby hashes are variables that can store collections of data.
3 |
4 |
5 | ### Learning Outcomes
6 | *Look through these now and then use them to test yourself after doing the assignment*
7 |
8 | * What's the difference between hashes and arrays?
9 | * How can you create a new hash?
10 | * How can you populate that hash with data?
11 | * What are keys and values in a hash?
12 | * How can you change existing values within a hash?
13 | * How can you delete existing data from a hash?
14 | * How can you merge two hashes together?
15 |
16 | ### Creating Hashes
17 |
18 | If an array is like a shelf of bins with numbers in ascending order on it, hashes take the analogy a step further by allowing you to write the labels on the outside of the bins, which lines up more with how people act in the real world.
19 |
20 | So, let's take a look at this shelf:
21 |
22 | ```ruby
23 | hash = { "random_word" => "ahoy", "Dorothy's math test score" => 94, "Guess what, literally another bin" => {} }
24 | ```
25 |
26 | Here's another set of bins, labeled, not 0, 1, and 2 (like on the 'array' shelf), but "random_word", "Dorothy's math test score", "Guess what, literally another bin". Since the labels here aren't numbers in ascending order starting at 0, we can be pretty sure that what we've got here is *a hash*.
27 |
28 | The above example is the most basic way to create a hash.
29 |
30 | There's a little bit to parse here, so let's take a breather and puzzle these bins out.
31 |
32 | One of the first things you might notice is that hashes use *curly braces* `{}` instead of *brackets* `[]`. That's an important one. It helps us distinguish hashes from arrays (useful, since they share a lot of functionality).
33 |
34 | The other thing you might notice is that hashes are made up of two parts: *keys* and *values*. A *key* is more or less analogous to an array's *index*, in that it's the label on the outside of the bin that helps us find what we're looking for. The *value* is what gets stored at a particular *key*. Keys and values are associated with a little operator called a 'hash rocket': `=>`.
35 |
36 | So that's what it looks like when a hash is created *literally* (e.g. `hash = { :whatever => "???" }`), but you can also call good old `#new` on the `Hash` class. If you give the `#new` method an argument, it'll even set a default value for keys that you don't specify:
37 |
38 | ```ruby
39 | hash = Hash.new
40 | hash["me"]
41 | => nil
42 | hash = Hash.new("you")
43 | hash["me"]
44 | => "you"
45 | hash["him"]
46 | => "you"
47 | ```
48 |
49 | Of course, hashes don't only take strings as keys and values. Ruby is a pretty flexible language so you can jam any old thing in there and it'll work just fine:
50 |
51 | ```ruby
52 | hash = { 9 => "nine", :six => 6 }
53 | hash[9]
54 | => "nine"
55 | hash[:six]
56 | => 6
57 | ```
58 |
59 | ### Adding data
60 |
61 | You can add to a hash the same way that you can add to an array. The easiest way is to call the key and set the value like you would with any other variable. Think of it like finding the right bin by its label and dropping something into the bin.
62 |
63 | ```ruby
64 | shoes = Hash.new
65 | shoes["summer"] = "sandals"
66 | shoes["winter"] = "boots"
67 | ```
68 |
69 | ### Accessing data
70 |
71 | You can get at that data the same way, e.g. `shoes["summer"] #=> "sandals"`. Hashes also come with a couple of sporty methods for finding what you need:
72 |
73 | ```ruby
74 | shoes["summer"]
75 | => "sandals"
76 | shoes.key("summer")
77 | => "sandals"
78 | ```
79 |
80 | Notice that when we call the hash's value by key, the key goes inside a pair of *brackets*, like when you're calling an array by index.
81 |
82 | ### Removing data
83 |
84 | The simple way to delete data from a hash is simply to call the value by its key and set it to `nil`:
85 |
86 | ```ruby
87 | shoes["winter"] = nil
88 | # And now we have no footwear in the snow.
89 | ```
90 |
91 | The fun way to delete data from a hash is to use the hash's `#delete` method, which provides the cool functionality of returning the value from the key-value pair was deleted from the hash. So:
92 |
93 | ```ruby
94 | shoes.delete("summer")
95 | => "sandals"
96 | shoes
97 | => {} # Empty hash, now that we have gotten rid of our shoes.
98 | ```
99 |
100 |
101 | ### Methods
102 |
103 | Hashes respond to just about all the same methods as arrays do, since they're both part of Ruby's *Enumerable* class. Keep an eye out in the next lesson on the Enumerable class for the difference in the way that arrays and hashes handle Enumerable methods -- the `#each` method especially.
104 |
105 | Another couple of useful methods for hashes are the `#keys` and `#values` methods, which do just what you think they do. Note that these methods return *arrays*.
106 |
107 | ```ruby
108 | books = { "Infinite Jest" => "David Foster Wallace", "Into the Wild" => "Jon Krakauer" }
109 | books.keys
110 | => ["Infinite Jest", "Into the Wild"]
111 | books.values
112 | => ["David Foster Wallace", "Jon Krakauer"]
113 | ```
114 |
115 | ### Merging two hashes
116 |
117 | It'll happen every now and again that two hashes need to come together in holy union. Luckily, there's a method for that.
118 |
119 | ```ruby
120 | hash1 = { "a" => 100, "b" => 200 }
121 | hash2 = { "b" => 254, "c" => 300 }
122 | hash1.merge(hash2)
123 | => { "a" => 100, "b" => 254, "c" => 300 }
124 | ```
125 |
126 | Note that the hash getting merged in (in this case, `hash2`), has precedence over the hash getting... uh, merged *at*, when both hashes share a key.
127 |
128 | For a list of methods that work on hashes, check out the [Ruby Docs](http://ruby-doc.org/core-2.1.1/Hash.html).
129 |
130 | ### Best practices
131 |
132 | In this explanation, we mostly used strings for hash keys, but in the real world, you'll see symbols like `:this_guy` as keys significantly more often. This is predominantly because symbols are a lot better performant than strings in Ruby, but also because they allow for a much cleaner syntax when defining hashes. Behold:
133 |
134 | ```ruby
135 | # 'Rocket' syntax
136 | american_cars = { :chevrolet => "Corvette", :ford => "Mustang", :dodge => "Ram" }
137 | # 'Symbols' syntax
138 | japanese_cars = { honda: "Accord", toyota: "Corolla", nissan: "Altima" }
139 | ```
140 |
141 | Notice that the 'hash rocket' and the colon that represents a symbol have been mashed together. This unfortunately only works for symbols, though, so don't try { 9: "value" }, or you'll get a syntax error.
142 |
143 | ### Assignment
144 | * Follow along Launch School's chapter on [Hashes](https://launchschool.com/books/ruby/read/hashes), and go through the exercises using IRB or any other REPL, such as [repl.it](https://repl.it/languages/ruby).
145 |
146 |
147 | ### Additional Resources
148 |
149 | *This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something*
150 |
151 | * Read through [Ruby Explained: Hashes](http://www.eriktrautman.com/posts/ruby-explained-hashes) by Erik Trautman.
152 |
--------------------------------------------------------------------------------
/new_course/1_programming_fundementals/input_and_output.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ### Introduction
4 | A brief summary about what this lesson is about and why the topics or concepts it covers are important.
5 |
6 | ### Learning Outcomes
7 | *Look through these now and then use them to test yourself after doing the assignment*
8 |
9 | what the student is expected to know or be able to do by the end of this lesson
10 |
11 | * Learning outcome 1
12 | * Learning outcome 2
13 | * Learning outcome 3
14 |
15 |
16 |
17 | ### Assignment
18 | The list of resources the user will go through to learn about the topic of this lesson. Have no more than 5 resources, ideally no more than three.
19 |
20 | ### Additional Resources
21 | *This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something*
22 |
23 | Link to no more than three additional resources to avoid this section becoming too cluttered.
24 |
--------------------------------------------------------------------------------
/new_course/1_programming_fundementals/loops.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | Loops, not to be confused with Fruit Loops, the addictive cereal that causes symptoms similar to ADHD in kids, are simply blocks of code that are continually repeated until a certain condition is met.
4 |
5 | Like me, you've probably experienced real life loops when you were given detention and made to write lines for drawing small phallic shapes on the desk at school. Writing the same lines over and over and over was not only boring, but potentially error prone. Maybe on one line you made a spelling mistake and on another you didn't dot an i. It's the same with programming: the less code you have to write, the less chance you have of introducing bugs that can cause your program to crash and burn.
6 |
7 | If you find yourself needing to repeat an action more than once in your code, you probably need loops in your life.
8 |
9 | It will be beneficial for you to code along to test the examples as you work through this lesson, either in IRB or [repl.it](https://repl.it/languages/ruby).
10 |
11 | ## Learning Outcomes
12 | *Look through these now and then use them to test yourself after doing the assignment*
13 |
14 | * You understand what a loop is and why it's useful
15 | * You know how to use the `loop` loop in Ruby
16 | * You know how to use the `while` loop in Ruby
17 | * You know how to use the `for` loop in Ruby
18 | * You know how to use the `times` loop in Ruby.
19 | * You know how to use the `until` loop in Ruby.
20 | * You know how to use the `upto` and `downto` loops in Ruby
21 |
22 | ### Loop
23 | The `loop` loop (say what????) is Ruby's loop that just don't quit. It's an infinite loop that'll keep going unless you specifically request for it to stop using the `break` command. Break is commonly used with a condition as illustrated in the code example below.
24 |
25 | ```ruby
26 | i = 0
27 | loop do
28 | puts "i is #{i}"
29 | i += 1
30 | break if i == 10
31 | end
32 | ```
33 |
34 | You won't see this loop used much in Ruby and if you're using it then there is probably a better loop for you out there.
35 |
36 | ### While Loop
37 |
38 | A `while` loop is similar to the `loop` loop except you declare the condition that will break out of the loop up front.
39 |
40 | ```ruby
41 | i = 0
42 | while(i < 10) do
43 | puts "i is #{i}"
44 | i += 1
45 | end
46 | ```
47 | This is an example of using a `while` loop with a count. Because you declare the condition that breaks the loop up-front, the intention of your code is much clearer, making it easier to read than our `loop` loop above.
48 |
49 | `while` loops can also be used to repeatedly ask a question of the user until they give an appropriate response:
50 |
51 | ```ruby
52 | while gets.chomp != "yes" do
53 | puts "Will you go to prom with me?"
54 | end
55 | ```
56 | In real life you obviously should just take no for an answer the first time.
57 |
58 |
59 | ### For Loop
60 |
61 | `for` loops are used to iterate through a collection of information such as an array or range.
62 |
63 | ```ruby
64 | for i in 0..5
65 | puts "The number of zombies I'd take out before succumbing is #{i}"
66 | end
67 | ```
68 | It's really all there is to it.
69 |
70 |
71 | ### Times Loop
72 |
73 | If you need to run a loop a specified number of times, then look no further than the trusty `times` loop. It works by iterating through a loop a set number of times that you specify and even throws in the bonus of accessing the number it's currently iterating through.
74 |
75 | ```ruby
76 | 5.times do
77 | puts "Hello, world!"
78 | end
79 | ```
80 | I'm sure you can guess what that code does. Ruby is readable that way!
81 |
82 | ```ruby
83 | 5.times do |number|
84 | puts "Alternative fact number #{number}"
85 | end
86 | ```
87 | Remember, loops will start counting from a zero index unless specified otherwise so the first loop iteration will output `Alternative fact number 0`.
88 |
89 |
90 | ### Until Loop
91 |
92 | The `until` loop is the opposite of the `while` loop. A `while` loop continues while the condition is true. An `until` loop continues while the condition is false, so they can be used pretty much interchangeably. It will ultimately be what your condition is checking that will determine which one is more readable.
93 |
94 | You should, as much as possible, avoid trying to negate your logical expressions using `!`(not) and this is where using `until` will shine.
95 |
96 | We can re-write our `while` loop examples, using `until`.
97 |
98 |
99 | ```ruby
100 | i = 0
101 | until(i > 10) do
102 | puts "i is #{i}"
103 | i += 1
104 | end
105 | ```
106 |
107 | You can see here that using `until` keeps running the loop while the condition is false.
108 |
109 | The second example shows how `until` can avoid the negation `!` that the `while` loops had to use.
110 |
111 | ```ruby
112 | until gets.chomp == "yes" do
113 | puts "Will you go to prom with me?"
114 | end
115 | ```
116 | Much more readable. Guaranteed to get you a yes.
117 |
118 |
119 | ### Upto and Downto Loops
120 |
121 | `upto` and `downto` are great examples of Ruby methods that do exactly what you'd think from the name. You can use these methods to iterate from a starting number either upto or downto another number.
122 |
123 | ```ruby
124 | 5.upto(10) {|num| print "#{num} " } #=> 5 6 7 8 9 10
125 |
126 | 10.downto(5) {|num| print "{num} " } #=> 10 9 8 7 6 5
127 | ```
128 |
129 | If you need to step through a series of numbers (or even letters) within a specific range, then these are the loops for you.
130 |
131 |
132 | ### Assignment
133 |
134 | * Try re-writing the above examples using alternative loop methods to achieve the same results.
135 |
136 | ## Further Reading
137 | *This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something*
138 |
139 | * If you need a different take and more examples on Loops, give this chapter by [LaunchSchool](https://launchschool.com/books/ruby/read/loops_iterators#simpleloop) a read through.
140 |
--------------------------------------------------------------------------------
/new_course/1_programming_fundementals/methods.md:
--------------------------------------------------------------------------------
1 | # Methods
2 | Methods, also known as functions, are one of the foundational building blocks in programming. Almost every language implements some way of making methods.
3 |
4 | You will often find yourself writing the same code in different places in your program. Wouldn't it be great if there was a way to reuse the same code over and over again without having to write it all out each time? This is what methods are for. They allow you to wrap sections of your code in a name, which you can then use where you need that code to be run in your program, and as many times as you need.
5 |
6 | This concept allows for what programmers refer to as the *D.R.Y.* approach to programming *-Don't Repeat Yourself-*. Recycling parts of code that would otherwise need to be repeated, often numerous times in several places, *can* make your program more readable and manageable.
7 |
8 | In this lesson we are going to deconstruct what methods are, their behaviour, and how they are used.
9 |
10 | ## Learning Outcomes
11 | *Look through these now and then use them to test yourself after doing the assignment*
12 |
13 | * You understand how to use Ruby's built in methods on objects
14 | * How would you create your own custom method?
15 | * How would you *call* your own method?
16 | * How do you pass variables to your method?
17 | * How do you define default parameters for your method?
18 | * What is the difference between an *explicit* and *implicit* return in your methods?
19 | * What is the difference between `puts` and `return`?
20 | * How do you chain multiple methods together?
21 | * Give an example of a valid method name and an invalid method name.
22 | * What does "snake case" naming mean?
23 | * What are some of Ruby's reserved words?
24 | * What do you call a method that returns `true` or `false`? How are they named?
25 | * What do bang methods do? How are they conventionally named?
26 |
27 | ## Ruby's Built in Methods
28 |
29 | One of Ruby's great advantages for new programmers is the large number of built-in methods it includes. You've been using many of them already, probably without even realizing it. Over the course of your learning so far, you have modified strings and other objects in various ways. Each time you have done this you have used a method.
30 |
31 | Methods are often applied by adding `.method_name` after an object you want to modify. (Though not all methods are used to modify an object).
32 |
33 | ```ruby
34 | "anything".reverse
35 | ```
36 |
37 | In this case, `reverse` is a method Ruby has built in for strings (and some others data types).
38 |
39 | `print` and `puts` are also methods. They are just called in a different way, by typing their name and passing them arguments.
40 |
41 | ```ruby
42 | puts "anything" #=> anything
43 | ```
44 |
45 | It's worth noting that in most languages, arguments are passed to methods by wrapping them in parentheses `()`. In Ruby, the parentheses are generally optional, so the above code is the same as `puts("anything")`. There will be exceptions to this rule that you will run into further into your learning.
46 |
47 |
48 | ## Creating a Method
49 |
50 | You can create your own custom methods in Ruby like so:
51 | ```ruby
52 | def my_name
53 | "Joe Smith"
54 | end
55 |
56 | puts my_name #=> "Joe Smith"
57 | ```
58 | Let's break it down:
59 | * `def` - is a built in Ruby keyword. It lets Ruby know this is the start of a method *definition*.
60 |
61 | * `my_name` - is the name you are giving to the method. You can pretty much name it whatever you want. But there are some constraints and conventions which are described in the next section.
62 |
63 | * `"Joe Smith"` - is in the *method body*. This is where all the logic of your method goes. This particular method will just *return* a string when it is *called*.
64 |
65 | * `end` - as you might have guessed `end` marks the *end* of the method definition. It's another Ruby keyword.
66 |
67 | * To call the method you simply need to use its name, as shown in the last line of the example `puts my_name`
68 |
69 |
70 | ## Parameters and Arguments
71 |
72 | Of course, not all methods are as simplistic as the example above. After all, what good are methods if you can't interact with them? When you need to return something other than a fixed result, you need methods with parameters. Parameters are variables that your method will receive when it is called. You can have more meaningful and useful interactions with your methods by using parameters to make them more versatile.
73 |
74 | ```ruby
75 | def greet(name)
76 | "Hello " + name + "!"
77 | end
78 |
79 | puts greet("John") #=> Hello John!
80 | ```
81 |
82 | In this simple example, `name` is a parameter that the `greet` method uses to return a more specific greeting. The method is called with the argument `"John"`, and returns the string "Hello John!"
83 |
84 | You might be confused when to use the term *argument* vs. *parameter*. Don't be: parameters effectively act as placeholder variables in the template that is your method, while arguments are the actual variables that get passed to the method when it is called. The two terms are commonly used interchangeably, so don't worry too much about it.
85 |
86 | ### Default Parameters
87 |
88 | What if you don't always want or need to provide arguments for each parameter that your method accepts? That's where default parameters can be useful. Going back to our simple example above, what if we don't know the person's name? We can code our `greet` method to use a default `name` of "stranger":
89 |
90 | ```ruby
91 | def greet(name = "stranger")
92 | "Hello " + name + "!"
93 | end
94 |
95 | puts greet("Jane") #=> Hello Jane!
96 | puts greet #=> Hello stranger!
97 | ```
98 |
99 | ## What Methods Return
100 |
101 | An important detail that a programmer must learn is understanding what your methods *return*. But how do we tell our methods what to return? Let's revisit our "Joe Smith" example:
102 |
103 | ```ruby
104 | def my_name
105 | "Joe Smith"
106 | end
107 |
108 | puts my_name #=> "Joe Smith"
109 | ```
110 |
111 | Our `my_name` method returns "Joe Smith". This may seem obvious, because it's the only thing inside the method. In most languages, however, such a method would not return anything, because it does not have an *explicit return* statement. Ruby is one of a few languages that employs *implicit returns* for methods.
112 |
113 | The above example could just as well be written with an explicit return:
114 |
115 | ```ruby
116 | def my_name
117 | return "Joe Smith"
118 | end
119 |
120 | puts my_name #=> "Joe Smith"
121 | ```
122 |
123 | With *implicit returns*, the rule to keep in mind is that Ruby methods always return the last expression which is evaluated. This may or may not be the last line in the code, as you can see in the following example.
124 |
125 | ```ruby
126 | def even_odd(number)
127 | if number % 2 == 0
128 | "That is an even number."
129 | else
130 | "That is an odd number."
131 | end
132 | end
133 |
134 | puts even_odd(16) #=> That is an even number.
135 | puts even_odd(17) #=> That is an odd number.
136 | ```
137 |
138 | Here, the method's return is dependent on the result of the `if` condition. If the argument is an even number, the expression inside the `else` statement never gets evaluated, so `even_odd` returns "That is an even number."
139 |
140 | *Explicit returns* can still have a place in Ruby code. Remember, Ruby returns the last expression evaluated. An *explicit return* (using the keyword `return`) essentially tells Ruby: "This is the last expression you should evaluate." Here's an example that shows how `return` stops the method from continuing.
141 |
142 | ```ruby
143 | def my_name
144 | return "Joe Smith"
145 | "Jane Doe"
146 | end
147 |
148 | puts my_name #=> "Joe Smith"
149 | ```
150 |
151 | Having a good understanding of just what your methods are returning is an important part of debugging your code when things don't behave as expected. Practice will help you understand this concept better.
152 |
153 | ### Difference between `puts` and `return`
154 |
155 | A common source of confusion for new programmers is the difference between `puts` and `return`.
156 |
157 | `puts` is an instruction (it's actually a method as you just learned) to print to the console whatever you tell it to.
158 | `return` is the final outcome of a method that you can make use of, as discussed in detail above. For example, you can have a method which calculates the multiplication of 3 and 10:
159 |
160 | ```ruby
161 | def dirty_thirty
162 | 3 * 10
163 | end
164 | ```
165 |
166 | You can then interact with this outcome in other places in your code:
167 |
168 | ```ruby
169 | puts "Yup I am turning " + dirty_thirty.to_s + " this year."
170 | #=> Yup I am turning 30 this year.
171 | ```
172 |
173 | You can see that the result (return) of the `dirty_thirty` method is just a piece of the output produced by this `puts` statement.
174 |
175 | ## Chaining Methods
176 |
177 | To keep you from having to write multiple lines when performing several actions (methods) on an object, Ruby allows you to chain your methods together. (This can be done with the built-in methods, or methods which you have written.)
178 |
179 | ```ruby
180 | phrase = ["be", "to", "not", "or", "be", "to"]
181 |
182 | puts phrase.reverse.join(" ").capitalize
183 | #=> To be or not to be
184 | ```
185 |
186 | You are effectively having each method building off of the outcome of the previous method in the chain. The process that takes place produces the following steps, in order:
187 |
188 | ```
189 | ["be", "to", "not", "or", "be", "to"].reverse
190 | = ["to", "be", "or", "not", "to", "be"].join(" ")
191 | = "to be or not to be".capitalize
192 | = "To be or not to be"
193 | ```
194 |
195 | ## Best practices
196 |
197 | We told you earlier that you can pretty much give your own methods any name you want. But you shouldn't do this haphazardly. For example, don't name your method `do_stuff`. There are certain conventions that are recommended in order to improve readability and maintainability of your code.
198 |
199 | You can use numbers, capital letters, lowercase letters, and the special characters `_`, `?`, `!`, and `=` in your method names. The convention for multiple words in a name is to use "snake_case", separating words with underscores.
200 |
201 | Here are some things you are not allowed to do:
202 | * You cannot name your method one of Ruby's approximately 40 reserved words, such `end`, `while`, or `for`. Do a quick scan of the [full list here](http://www.java2s.com/Code/Ruby/Language-Basics/Rubysreservedwords.htm)
203 | * You cannot use any symbols other than `_`, `?`, `!`, and `=`
204 | * You cannot use `?`, `!`, or `=` anywhere other than at the end of the name
205 | * You cannot begin a method name with a number
206 |
207 | Some examples of valid and invalid method names:
208 |
209 | ```
210 | method_name # valid
211 | _name_of_method # valid
212 | 1method_name # invalid
213 | method_27 # valid
214 | method?_name # invalid
215 | method_name! # valid
216 | begin # invalid (Ruby reserved word by itself)
217 | begin_count # valid
218 | ```
219 |
220 | ### Too Long a Name / Too Many Parameters
221 |
222 | In general, short but descriptive is the name of the naming-game. You want to be able to tell what a method is expected to do based on its name.
223 |
224 | Another thing to consider is that, if your method does too many things such that you feel it requires a very long name, then your method should probably be broken up into several smaller/simpler methods. Methods should in reality only do one thing. This practice will pay dividends down the road, again for readability, scalability and maintainability. (It also makes testing your code a lot easier, which will be covered in a later lesson.)
225 |
226 | The same idea applies if you find your method accepting too many parameters/arguments. If it is accepting numerous arguments, it is probably doing too many things, and should be broken up into individual simpler methods doing individual tasks.
227 |
228 |
229 | ### Predicate Methods
230 |
231 | You will at times encounter some built-in Ruby methods that have a `?` mark at the end of their name. Such as `even?`, `odd?`, `between?` and many more. These are called `predicate` methods. Ruby uses this naming convention for any method that strictly returns a Boolean, that is either `true` or `false`.
232 |
233 | ```ruby
234 | puts 5.even? #=> false
235 | puts 6.even? #=> true
236 | puts 17.odd? #=> true
237 |
238 | puts 12.between?(10, 15) #=> true
239 | ```
240 |
241 | You can also name your own methods with a `?` a the end to indicate your method returns a Boolean. (Just note that Ruby does not enforce this, but you will thank yourself later for following this convention).
242 |
243 | ### Bang Methods
244 |
245 | Observe the example below:
246 |
247 | ```ruby
248 | whisper = "HELLO EVERYBODY"
249 |
250 | puts whisper.downcase #=> hello everybody
251 | puts whisper #=> HELLO EVERYBODY
252 | ```
253 |
254 | What gives? I thought we downcased that thing! So why did it not change when we called it again?
255 |
256 | What happens is that calling a method on an object, such as our string above, does not actually modify the original value of that object. A general rule in programming is that you do not want your methods to overwrite the objects you call them on. This is to protect you from irreversibly overwriting your data by accident. Though you *ARE* able to do so by explicitly re-assigning a variable (such as whisper = whisper.downcase). But another way to do this is with *bang methods*, which are denoted with the `!` symbol.
257 |
258 | By just adding a `!` to the end of your method, you are indicating that this method is going to perform its action and also apply the result to override the value of the original object.
259 |
260 | ```ruby
261 | puts whisper.downcase! #=> hello everybody
262 | puts whisper #=> hello everybody
263 | ```
264 |
265 | Writing `whisper.downcase!` is the equivalent of writing `whisper = whisper.downcase`.
266 |
267 | ## Assignment
268 | 1. To get a good introduction to all the different concepts related to methods read [this chapter about methods](https://launchschool.com/books/ruby/read/methods) from Launch School's Introduction to Programming with Ruby book. Make sure to do the exercises at the end of the chapter too.
269 | 2. For a deeper look at methods read [this chapter](http://ruby.bastardsbook.com/chapters/methods/) from the Bastards book of Ruby. Again try to complete the exercises throughout the chapter.
270 |
271 | ## Further Reading
272 | *This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something*
273 |
274 | 1. Within the context of Ruby, you will only be writing methods. But for future learning, as you add more languages to your repertoire (cause any seasoned programmer worth their salt eventually will have learned several languages over the course of their careers), here is a [handy explanation on Stack Overflow](https://stackoverflow.com/questions/155609/difference-between-a-method-and-a-function) on the subtle differences between methods and functions, and how they can differ by language.
275 |
--------------------------------------------------------------------------------
/new_course/1_programming_fundementals/primitive_data_types.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 |
4 | ### Learning Outcomes
5 | *Look through these now and then use them to test yourself after doing the assignment*
6 |
7 | * Strings
8 | * What is a string?
9 | * What's the difference between single and double quotes?
10 | * What is string interpolation?
11 | * How do you concatenate strings?
12 | * What method would you use to change all the characters in your string to upper case?
13 | * What method would you use to _split_ up strings into arrays?
14 | * What are escape characters?
15 | * How do you access a specific character or substring?
16 | * How do you convert other data types into strings?
17 |
18 | * Numbers
19 | * What are the basic arithmetic operators you can use on numbers?
20 | * What's the difference between an integer and a float?
21 | * What method would you use to convert a float to an integer?
22 | * What method would you use to convert an integer to a float?
23 |
24 | * Symbols
25 | * What is a symbol?
26 | * What's the difference between a symbol and a string?
27 | * How do you create a symbol?
28 |
29 | * true, false and nil
30 | * What does `true` represent?
31 | * What does `false` represent?
32 | * What does `nil` represent?
33 |
34 |
35 | ### Numbers
36 | You probably already know what numbers are so there's no need to go into elaborate
37 | metaphors here.
38 |
39 | Ruby has all the typical math operators you would expect:
40 |
41 | ```ruby
42 | # addition
43 | 1 + 1 #=> 2
44 |
45 | # subtraction
46 | 2 - 1 #=> 1
47 |
48 | # multiplication
49 | 2 * 2 #=> 4
50 |
51 | # division
52 | 10 / 5 #=> 2
53 |
54 | # modulus (find the remainder from division)
55 | 10 % 4 #=> 2
56 |
57 | # exponent
58 | 2 ** 2 #=> 4
59 | 3 ** 4 = => 83
60 | ```
61 |
62 | #### Integers and Floats
63 | There are two main types of number in Ruby:
64 |
65 | **Integers** are whole numbers such as 10.
66 |
67 | **Floats** are numbers which have a decimal point such as 10.5.
68 |
69 | Here's one of the gotchas to bear in mind when working with integers and floats:
70 |
71 | When doing arithmetic with two integers, the result will always be an integer.
72 | Even if you didn't want it to be.
73 |
74 | ```ruby
75 | 17 / 5 #=> 3
76 | ```
77 |
78 | To solve this problem, just replace one of the integers with a float in the expression.
79 |
80 | ```ruby
81 | 17 / 5.0 #=> 3.4
82 | ```
83 |
84 | #### Converting Number Types
85 | Ruby makes it very easy to convert numbers to and from floats or integers with a couple of
86 | methods.
87 |
88 | ```ruby
89 | # converting a float to an integer
90 | 13.0.to_i #=> 13
91 |
92 | # converting to a integer to a float
93 | 13.to_f #=> 13.0
94 | ```
95 | When converting from a float to an integer remember that the decimal places will effectively be cut off so only the whole (integer) remains. It won't do any rounding to the closest number.
96 |
97 | #### Some Useful Number Methods
98 | There are a lot of very useful methods you can use built into Ruby. A couple quick examples:
99 |
100 | **even?**
101 | ```ruby
102 | 6.even? #=> true
103 | 7.even? #=> false
104 | ```
105 |
106 | **odd?**
107 | ```ruby
108 | 6.odd? #=> false
109 | 7.odd? #=> true
110 | ```
111 |
112 | ### Strings
113 | Strings, strings, wonderful things, use them well and your app will grow wings. Or something.
114 |
115 | At first glance, you'd be forgiven for thinking strings are just a bunch of characters that aren't very useful beyond getting user input and outputting some information to the screen, but like Burt Reynolds passing up the chance of playing Han Solo, you'd be wrong. Very wrong. What were you thinking Burt?
116 |
117 | From the prep course, you should have a good understanding of strings so we won't bore you to death recapping what you already know. Instead we'll just cover some of the pitfalls and more interesting features and let the reading assignments do the rest.
118 |
119 | #### double and single quotes in strings
120 | Strings can be formed with either double `""` or single`''` quotes. They are pretty similar but there are some differences.
121 |
122 | #### Interpolation
123 | Use double quotes for string interpolation.
124 |
125 | ```ruby
126 | name = "Odin"
127 | puts "Hello, #{name}" #=> "Hello, Odin"
128 | puts 'Hello, #{name}' #=> "Hello, #{name}"
129 | ```
130 |
131 | #### Concatenation
132 | In true Ruby style, there are plenty of ways to concatenate strings.
133 |
134 | ```ruby
135 | # with the plus operator
136 | "Welcome " + "to " + "Odin!" #=> "Welcome to Odin!"
137 |
138 | # with the shovel operator
139 | "Welcome " << "to " << "Odin!" # "Welcome to Odin!"
140 |
141 | # with the concat method
142 | "Welcome ".concat("to ").concat("Odin!") #=> "Welcome to Odin!"
143 | ```
144 | Classic Ruby!
145 |
146 | #### Common string methods
147 | There are a lot of useful methods you can use that are built into Ruby. Someone needs you to capitalize a word? No problem! Reverse a string? Not all heroes wear capes. Extract the binary subatomic algorithm from any regex grep? Errrrrrrrr, yeah totally.
148 |
149 | Just remember, strings have loads of methods provided to you for free and you can find them all in the [Ruby docs](ruby-doc.org/core-2.4.0/String.html). If you're working with strings and need to do something, check the Ruby Docs first and see if there is one that does it for you.
150 |
151 | Below is a quick recap on the more common methods you might find yourself using. Feel free to follow along to these in irb or [repl.it](https://repl.it/languages/ruby) to get a feel for them.
152 |
153 | **capitalize**
154 | ```ruby
155 | "hello".capitalize #=> "Hello"
156 | ```
157 |
158 | **include?**
159 | ```ruby
160 | "hello".include?("lo") #=> true
161 |
162 | "hello".include?("z") #=> false
163 | ```
164 |
165 | **upcase**
166 | ```ruby
167 | "hello".upcase #=> "HELLO"
168 | ```
169 | **downcase**
170 | ```ruby
171 | "Hello".downcase #=> "hello"
172 | ```
173 |
174 | **empty?**
175 | ```ruby
176 | "hello".empty? #=> false
177 |
178 | "".empty? #=> true
179 | ```
180 |
181 | **length**
182 | ```ruby
183 | "hello".length #=> 5
184 | ```
185 |
186 | **reverse**
187 | ```ruby
188 | "hello".reverse #=> "olleh"
189 | ```
190 |
191 | **split**
192 | ```ruby
193 | "hello world".split #=> ["hello", "world"]
194 | ```
195 | **strip**
196 | ```ruby
197 | " hello, world ".strip #=> "hello, world"
198 | ```
199 |
200 | #### Substrings
201 | You can access strings inside strings inside strings. Stringception! It's super easy too.
202 |
203 | ```ruby
204 | "hello"[0] #=> "h"
205 |
206 | "hello"[0..1] #=> "he"
207 |
208 | "hello"[0, 4] #=> "hell"
209 |
210 | "hello"[-1] #=> "o"
211 |
212 | "hello dude"[0,5][1..3] #=> "ell". I have no idea why you'd want to do this, but you can!
213 | ```
214 |
215 | #### Escape Characters
216 | Hopefully these are self explanatory. Use them if you need them in your code. There may be some gotchas with single quotes so use double quotes to be safe.
217 |
218 | ```ruby
219 | \\ #=> Need a backslash in your string?
220 | \b #=> Backspace
221 | \r #=> Carriage return, For you oldies that love typewriters
222 | \n #=> Newline. You'll use this one.
223 | \s #=> Space
224 | \t #=> Tab
225 | \" #=> Double Quote
226 | \' #=> Single Quote
227 | ```
228 | The best thing to do is play around with them in a Repl.
229 |
230 |
231 | #### String Manipulation
232 | You'll read about these in the assignments. So I'll just leave some examples to get your creative juices flowing thinking about some awesome ways to actually modify strings.
233 |
234 | ```ruby
235 | "he77o".sub("7", "l") #=> "hel7o"
236 |
237 | "he77o".gsub("7", "l") #=> "hello"
238 |
239 | "hello".insert(-1, " dude") #=> "hello dude"
240 |
241 | "hello".split("") #=> ["h", "e", "l", "l", "o"]
242 |
243 | "!".prepend("hello ", "world") #=> "hello, world!"
244 | ```
245 |
246 | The assignments will go deeper and clarify more than I have, so go through them and be sure to play around in a Repl.
247 |
248 | #### Converting other objects to strings
249 | Using the `to_s` method, you can convert pretty much anything to a string, here are some examples:
250 |
251 | ```ruby
252 | 5.to_s #=> "5"
253 |
254 | nil.to_s #=> ""
255 |
256 | :symbol.to_s #=> "symbol"
257 | ```
258 |
259 | ### Symbols
260 |
261 | Symbols are an interesting twist on the idea of a string. The real explanation can be a bit long, but here's the short version:
262 |
263 | Strings can be changed, so every time a string is used, Ruby has to store it in memory even if an existing string with the same value already exists. Symbols on the other hand are stored in memory once. This makes symbols faster than strings at certain things.
264 |
265 | One use for symbols over strings are as keys in hashes. We'll cover this in detail in the hashes lesson later in the course.
266 |
267 | You won't need to use symbols much in the beginning, but it's good to get familiar with what they are and what they look like so you can recognise them in Ruby code.
268 |
269 | #### Create a Symbol
270 | To create a symbol simply put a colon at the beginning of some text
271 | ```
272 | :my_symbol
273 | ```
274 |
275 |
276 |
277 | #### Symbols vs Strings
278 | To get a better idea of how symbols are stored in memory, give this a whirl in irb or repl.it.
279 |
280 | ```ruby
281 | "string" == "string"
282 | => true
283 | "string".object_id == "string".object_id
284 | => false
285 | :symbol.object_id == :symbol.object_id
286 | => true
287 | ```
288 |
289 |
290 | ### True, false and nil
291 | You will learn about these data types in more detail in the conditional logic lesson later in this course. Until then it will be beneficial to have a basic understanding of what they are.
292 |
293 | #### true and false
294 | These represent exactly what you think. `true` represents something which is true and `false` represents the opposite.
295 |
296 | #### nil
297 | Nil represents 'nothing'. Everything in Ruby has a return value. When a piece of code doesn't have anything to return, it will return `nil`. This is pretty abstract but it will make more sense as you learn and use Ruby more in depth.
298 |
299 | ### Assignment
300 |
301 | 1. Read the [Basics chapter](https://launchschool.com/books/ruby/read/basics) of LaunchSchool's Introduction to Programming Book for an different explanation of Ruby's data types.
302 | 2. Read through these Ruby Monstas sections about data types:
303 | * [Numbers](http://ruby-for-beginners.rubymonstas.org/built_in_classes/numbers.html)
304 | * [Strings](http://ruby-for-beginners.rubymonstas.org/built_in_classes/strings.html)
305 | * [Symbols](http://ruby-for-beginners.rubymonstas.org/built_in_classes/symbols.html)
306 | * [True, False and Nil](http://ruby-for-beginners.rubymonstas.org/built_in_classes/true_false_nil.html)
307 |
308 |
309 | ### Additional Resources
310 | *This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something*
311 |
312 | * If you want to go deeper into Ruby's numbers and strings data types read these chapters from the Bastards Book of Ruby
313 | * [Numbers](http://ruby.bastardsbook.com/chapters/numbers/)
314 | * [Strings](http://ruby.bastardsbook.com/chapters/strings/)
315 |
--------------------------------------------------------------------------------
/new_course/1_programming_fundementals/problem_solving.md:
--------------------------------------------------------------------------------
1 | # Problem Solving
2 | A brief summary about what this lesson is about and why the topics or concepts it covers are important.
3 |
4 | ## Learning Outcomes
5 | *Look through these now and then use them to test yourself after doing the assignment*
6 |
7 | what the student is expected to know or be able to do by the end of this lesson
8 |
9 | * Learning outcome 1
10 | * Learning outcome 2
11 | * Learning outcome 3
12 |
13 | ## The Problem solving Process
14 |
15 | First
16 | * Identify the big picture goal - what problem are you trying to solve?
17 | * How will you interact with the software? sketch the interface
18 |
19 | Then
20 | * whats the smallest possible feature you can build to get started?
21 | * pseudo code for the feature
22 | * Implement
23 | * repeat
24 |
25 | ## Deep Dive into Pseudo Coding
26 | * what is it?
27 | - plain english representation of the code you will write
28 | - also known as an algorithm
29 |
30 | * how to do it
31 | - step by step sequence starting from the top like a recipe
32 | - show examples of pseudo coding a problem
33 |
34 |
35 | ### Assignment
36 | http://www.slideshare.net/DamianGordon1/pseudocode-10373156
37 |
38 | https://getpocket.com/a/read/62846566
39 |
40 | https://ocw.mit.edu/resources/res-tll-004-stem-concept-videos-fall-2013/videos/problem-solving/basic-programming-techniques/
41 |
42 | ## Exercises
43 | A group of exercises (If Applicable) for the student to complete in relation to the topic taught in the lesson.
44 |
45 | ### Additional Resources
46 | *This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something*
47 |
48 | Link to no more than three additional resources to avoid this section becoming too cluttered.
49 |
--------------------------------------------------------------------------------
/new_course/1_programming_fundementals/variables.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 | Variables are a way of assigning names to things in your programs. You can think of a variable as a box with a label on it, they store something and have a name so you know what's inside them. This is an imperfect metaphor as you'll see by the end of this lesson but it should help with understanding variables for now.
3 |
4 | ### Learning Outcomes
5 | *Look through these now and then use them to test yourself after doing the assignment*
6 |
7 | * What is a variable?
8 | * How do you assign a value or an expression to a variable?
9 | * What does the `+=` assignment operator do?
10 | * What does the `-=` assignment operator do?
11 | * What does the `*=` assignment operator do?
12 | * What are the variable naming conventions?
13 |
14 | ### Declaring a Variable
15 | This is how you make a variable in Ruby:
16 |
17 | ```ruby
18 | age = 18 #=> 18
19 | ```
20 |
21 | You can also assign a variable's value as the result of an expression.
22 |
23 | ```ruby
24 | age = 18 + 5 #=> 23
25 | ```
26 |
27 | Variables names are reusable, you can assign them to a new value at any point in your program.
28 | This will override the value that is currently in the variable. Here's an example of that.
29 |
30 | ```ruby
31 | age = 18
32 | age #=> 18
33 | age = 33
34 | age #=> 33
35 | ```
36 |
37 | There will often be scenarios where you will want to do an operation to the original
38 | value of a variable and reassign that variable to the result of that operation. This
39 | is how you would do that:
40 |
41 | ```ruby
42 | age = 18
43 | age #=> 18
44 | age = age + 4
45 | age #=> 22
46 | ```
47 |
48 | Because this is a common scenario, Ruby provides a nice short hand
49 | assignment operator for doing this `+=`:
50 |
51 | ```ruby
52 | age = 18
53 | age += 4 #=> 22
54 | ```
55 |
56 | There are assignment operators like this for all the common math operators:
57 |
58 | ```ruby
59 | age = 18
60 | age -= 2 #=> 16
61 |
62 | cash = 10
63 | cash *= 2 #=> 20
64 |
65 | temperature = 40
66 | temperature /= 10 #=> 4
67 | ```
68 |
69 | ### How to Name Variables
70 | Ruby is a language which aims to be natural to read and easy to write. Remember this when you're naming your variables. The name should, as clearly as possible, aim to describe what the value of the variable represents.
71 |
72 | Naming variables will pay dividends when you review your code months after you've written it, when you can no longer clearly remember what that variable was designed to store. From now on, when naming your variables, remember the following quote by John Woods.
73 |
74 | > Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
75 |
76 | The most basic thing you can do to write clean, maintainable code is name your variables properly. So get into this habit early to avoid psychopath programmers coming after you.
77 |
78 | Variable names should always be lowercase and multiple words that make up a variable name should be split by an underscore. This is known as _snake_case_.
79 |
80 | ```ruby
81 | # bad
82 | a = "Hello"
83 | number = 2
84 |
85 | # good
86 | age = 19
87 | name = "John"
88 | can_swim = false
89 | ```
90 |
91 | ### Variables are References
92 | The information you name with a variable is stored in memory on your computer. So a variable is effectively a reference or a pointer to that address in memory. This can sometimes be the cause of unexpected behaviours from your code.
93 |
94 |
95 | In the following example we have two variables, `desired_location` which is assigned to the string "Barcelona" and `johns_location` which is assigned to the `desired_location` variable. Both variables are pointing to where "Barcelona" is stored in memory.
96 |
97 | ```ruby
98 | desired_location = "Barcelona"
99 | johns_location = desired_location
100 |
101 | desired_location #=> "Barcelona"
102 | johns_location #=> "Barcelona"
103 | ```
104 |
105 | This means if we modify the string "Barcelona" it will in turn change the value of both variables.
106 |
107 | ```ruby
108 | johns_location.upcase! #=> "BARCELONA"
109 |
110 | desired_location #=> "BARCELONA"
111 | johns_location #=> "BARCELONA"
112 | ```
113 |
114 | ### Assignment
115 | 1. Read the [variables chapter](https://launchschool.com/books/ruby/read/variables) from the Launch School's brilliant Introduction to Programming with Ruby Book.
116 | 2. Read through these short, to the point variable lessons by Ruby Monstas
117 | * [Overview of Variables](http://ruby-for-beginners.rubymonstas.org/variables.html)
118 | * [Reusing Variables](http://ruby-for-beginners.rubymonstas.org/variables.html)
119 | * [Things on the Right go First](http://ruby-for-beginners.rubymonstas.org/variables/right_goes_first.html)
120 | 3. Open up a [Ruby Repl](https://repl.it/languages/ruby) or IRB in your command line and try naming some variables and assigning some values to them. Don't try at this stage to name good variables but instead experiment with different variable names, run the Repl and see if it's valid. Try using symbols or numbers in your variable names. See what works and what doesn't. If you come across anything quirky, google it to find out why.
121 |
122 |
123 | ### Additional Resources
124 | *This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something*
125 | * Read the full [Variables chapter](http://ruby.bastardsbook.com/chapters/variables) from The Bastards Book of Ruby if you can't get enough about variables.
126 | * To dive deeper into how variables point to memory locations on your computer, go through these couple of short sections:
127 | * [Variables as pointers from Introduction To Programming with Ruby by Launch School](https://launchschool.com/books/ruby/read/more_stuff#variables_as_pointers)
128 | * [A visual Guide to how Variables work from the Variables chapter in The Bastards Book of Ruby](http://ruby.bastardsbook.com/chapters/variables/#visual-guide)
129 |
--------------------------------------------------------------------------------
/ruby_programming/basic_ruby/lesson_advanced_building_blocks.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | This lesson gets more into the topics you may have been shaky on before like *Control Flow, Looping, Arrays, Hashes, Blocks, Sorting*. It's definitely got some more meat to it than the previous one. The projects in the Assignment section are good for doing on your own because Codecademy gives you all kinds of help with them.
4 |
5 | ### Learning Outcomes
6 | Look through these now and then use them to test yourself after doing the assignment:
7 |
8 | #### Conditionals and Flow Control:
9 | * What is a "boolean"?
10 | * What are "truthy" values?
11 | * Are `nil`, `0`, `"0"`, `""`, `1`, `[]`, `{}` and `-1` considered true or false?
12 | * When do you use `elsif`?
13 | * When do you use `unless`?
14 | * What does `<=>` do?
15 | * Why might you define your own `<=>` method?
16 | * What do `||` and `&&` and `!` do?
17 | * What is returned by `puts("woah") || true`?
18 | * What is `||=`?
19 | * What is the ternary operator?
20 | * When should you use a `case` statement?
21 |
22 | #### Iteration:
23 | * What does `loop` do?
24 | * What are the two ways to denote a block of code?
25 | * What is an index variable?
26 | * How do you print out each item of a simple array `[1,3,5,7]` with:
27 | * `loop`?
28 | * `while`?
29 | * `for`?
30 | * `#each`?
31 | * `#times`?
32 | * What's the difference between `while` and `until`?
33 | * How do you stop a loop?
34 | * How do you skip to the next iteration of a loop?
35 | * How would you start the loop over again?
36 | * What are the (basic) differences between situations when you would use `while` vs `#times` vs `#each`?
37 | * What does nesting loops mean and when would you use it?
38 |
39 | #### Blocks, Procs, and Lambdas:
40 | * How is a block like a function?
41 | * How is a block different from a function?
42 | * What are the two ways to declare a block?
43 | * How do you return data from a block?
44 | * What happens if you include a `return` statement in a block?
45 | * Why would you use a block instead of just creating a method?
46 | * What does `yield` do?
47 | * How do you pass arguments to a block from within a method?
48 | * How do you check whether a block was actually passed in?
49 | * What is a proc?
50 | * What's the difference between a proc and a block?
51 | * When would you use a proc instead of a block?
52 | * What is a closure?
53 | * What is a lambda?
54 | * What's different between a lambda and a proc?
55 | * What is a Method (capital "M")?
56 | * What do Methods basically allow you to do that could probably be pretty interesting when you're writing some more advanced programs later on?
57 |
58 | #### Enumerable and Modules:
59 | * What is a module?
60 | * Why are modules useful?
61 | * What does `#each` do?
62 | * What does `#each` return?
63 | * What does `#map` do?
64 | * What does `#map` return?
65 | * What is the difference between `#map` and `#collect`?
66 | * What does `#select` do?
67 | * What does `#select` return?
68 | * What is the difference between `#each` `#map` and `#select`?
69 | * What does `#inject` do?
70 | * When might you use `#inject`?
71 | * How do you check if every item in a hash fulfills a certain criteria?
72 | * What about if none of the elements fulfill that criteria?
73 | * What (basically) is an `enumerator`?
74 |
75 | #### Writing Methods:
76 | * How many things should a method ideally do?
77 | * What types of things should a method modify?
78 | * What should you name a method?
79 | * What does `self` mean?
80 | * What do you need to do to create your own Ruby script file?
81 | * How would you run a Ruby script from the command line?
82 | * How can you check whether your script was being run from the command line?
83 | * What is a shebang line?
84 | * What does `require` do?
85 | * What does `load` do?
86 | * What is the difference between `require` and `load`?
87 | * How do you access any parameters that were passed to your script file from the command line?
88 | * What does `#send` do?
89 | * When would `#send` be used that's different from just running the method on an object 'normally'?
90 |
91 | ### Assignment
92 |
93 |
94 | 1. Do the [Codecademy Ruby sections 2-8](https://www.codecademy.com/learn/learn-ruby), including:
95 | 1. Control Flow in Ruby
96 | 2. Project: Thith Meanth War!
97 | 2. Looping with Ruby
98 | 3. Project: Redacted!
99 | 3. Arrays and Hashes
100 | 4. Blocks and Sorting
101 | 4. Project: Ordering your Library
102 | 5. Hashes and Symbols
103 | 6. Project: A Night at the Movies
104 | 7. The Zen of Ruby
105 | 8. The Refactor Factory
106 | 9. Blocks, Procs, and Lambdas
107 | 2. Finish [Beginning Ruby](https://books.google.com.pk/books?id=MiGpDAAAQBAJ&printsec=frontcover#v=onepage&q&f=false) Chapter 3: `Ruby's Building Blocks: Data, Expressions, and Flow Control` (pages 47-71)
108 | 3. For a look at underserved concepts and help with the questions above, check out these posts by Erik Trautman:
109 | 1. [Ruby Explained: Conditionals and Flow Control](http://www.eriktrautman.com/posts/ruby-explained-conditionals-and-flow-control)
110 | 2. [Ruby Explained: Iteration](http://www.eriktrautman.com/posts/ruby-explained-iteration)
111 | 3. [Ruby Explained: Blocks, Procs, and Lambdas, aka "Closures"](http://www.eriktrautman.com/posts/ruby-explained-blocks-procs-and-lambdas-aka-closures)
112 | 5. [Ruby Explained: Map, Select, and Other Enumerable Methods](http://www.eriktrautman.com/posts/ruby-explained-map-select-and-other-enumerable-methods)
113 | 6. [Ruby Explained: Writing and Running Methods](http://www.eriktrautman.com/posts/ruby-explained-writing-and-running-methods)
114 |
115 |
116 | ### Test Yourself
117 |
118 | Make sure you can do the following quizzes from [Code Quizzes](http://www.codequizzes.com/). They're pretty quick and should give you an idea of what you still need to brush up on.
119 |
120 |
121 | 1. [Beginner Ruby Quiz #2](http://www.codequizzes.com/ruby/beginner/arrays-conditionals-loops)
122 | 2. [Quiz #3](http://www.codequizzes.com/ruby/beginner/variable-scope-methods)
123 | 3. [Quiz #4](http://www.codequizzes.com/ruby/beginner/symbols-array-methods-hashes)
124 | 4. [Quiz #6](http://www.codequizzes.com/ruby/beginner/iteration-nested-data-structures)
125 | 5. Make sure you go back up and look at all the questions from the "Learning Outcomes" section. See if you can do most of them without looking back through the text.
126 |
127 |
128 | ### Additional Resources
129 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
130 |
131 | * Still unsure about Enumerable? Check out the [Enumerable Chapter of the Bastard's Book](http://ruby.bastardsbook.com/chapters/enumerables/)
132 | * Github Gist on [Truthiness](https://gist.github.com/jfarmer/2647362)
133 | * See [these answers on the Spaceship Operator](http://stackoverflow.com/questions/827649/what-is-the-ruby-spaceship-operator)
134 | * Read [Zetcode's Flow Control section](http://zetcode.com/lang/rubytutorial/flowcontrol/) for more depth on flow control.
135 | * If you want a bit more, check out [Skork's entry on Ruby looping and iterators](http://www.skorks.com/2009/09/a-wealth-of-ruby-loops-and-iterators/)
136 | * [Why can you either `yield` to blocks or make them explicit? Who cares? (from SO)](http://stackoverflow.com/questions/1410160/ruby-proccall-vs-yield)
137 | * [Writing your Own Methods](http://rubylearning.com/satishtalim/writing_own_ruby_methods.html)
138 | * A quick guide on writing methods from [wikibooks](http://en.wikibooks.org/wiki/Ruby_Programming/Writing_methods)
139 | * [Getting to Hello World](http://en.wikibooks.org/wiki/Ruby_Programming/Hello_world)
140 | * [LRTHW chapters 13-14](http://ruby.learncodethehardway.org/book/)
141 | * [Converting between Blocks & Procs](https://medium.com/@sihui/proc-code-block-conversion-and-ampersand-in-ruby-35cf524eef55)
142 | * Want to get some feedback on your code? Try problems and submit your solutions on [Exercism](http://exercism.io/languages/ruby)
143 |
--------------------------------------------------------------------------------
/ruby_programming/basic_ruby/lesson_building_blocks.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | Welcome to Ruby Building Blocks! Since you've already done a decent chunk of Ruby in the [Web Development 101 Course](https://www.theodinproject.com/courses/web-development-101/lessons/ruby-basics) (if not, go do that first!), this should start as a healthy refresher of what you've already learned with *Variables, Data Types, Strings, and Methods*.
4 |
5 | But this lesson will take you much deeper and further than you went before, so don't think you've got a free pass. There's a whole lot of stuff to cover. These first couple of lessons cover the broadest swathe of material of the entire Ruby course, so get stretched out and warmed up, it's time to dive in!
6 |
7 | ### Learning Outcomes
8 | Look through these now and then use them to test yourself after doing the assignment:
9 |
10 | #### Numbers, Operators and Expressions:
11 | * What's the difference between an `Integer` and a `Float`?
12 | * Why should you be careful when converting back and forth between integers and floats?
13 | * What's the difference between `=`, `==`, and `===`?
14 | * How do you do exponents in Ruby?
15 | * What is a `range`?
16 | * How do you create a range?
17 | * What's the difference between `(1..3)` and `(1...3)`?
18 | * What are three ways to create a range?
19 |
20 | #### Strings:
21 | * What's the difference between single and double quotes?
22 | * What is string interpolation?
23 | * What are escape characters?
24 | * What are line breaks?
25 | * How do you make other things into strings?
26 | * How do you concatenate strings?
27 | * How do you access a specific character or substring?
28 | * How do you split up strings into arrays?
29 | * How are strings and arrays similar?
30 | * How do you get and clean up user input on the command line?
31 | * What does it mean that strings are "mutable" and why care?
32 | * What is a symbol?
33 | * How is a symbol different from a string?
34 | * What is a Regular Expression (RegEx)?
35 | * How can you center or right-justify a string?
36 |
37 | #### Arrays:
38 | * What are three ways to create an array?
39 | * How do you prepopulate the array with default data?
40 | * How do you access items in an array?
41 | * How can you access a specific group of items in an array?
42 | * How do you modify the items in an array?
43 | * How do you combine arrays?
44 | * How do you find the values in one array that aren't in another?
45 | * How do you find values in both arrays?
46 | * What is the difference between `push`/`pop` and `shift`/`unshift`?
47 | * What is the shovel operator?
48 | * How is `> arr.pop` different from `> arr[-1]`?
49 | * How is `push`ing or `<<`ing another array into your array different from just adding them together?
50 | * How do you delete items in an array?
51 | * Why should you be careful deleting items in an array?
52 | * How can you convert arrays to strings?
53 | * How can you convert from other data types to arrays?
54 | * How can you figure out if an array contains a particular value?
55 | * How do you find the biggest item in an array?
56 | * How do you find the smallest item in an array?
57 | * How do you remove any duplicates from your array?
58 | * How do you find out how big an array is?
59 | * How do you put an array in order?
60 | * What are the naming conventions for arrays?
61 | * What should you store in arrays?
62 |
63 | #### Hashes:
64 | * What is a hash?
65 | * What are keys and values?
66 | * How is a hash similar to an Array?
67 | * How is a hash different from an Array?
68 | * What are 3 ways to create a hash?
69 | * What is the hash rocket?
70 | * How do you access data in a hash?
71 | * How do you change data in a hash?
72 | * What types of data are good to store in a hash?
73 | * What are options hashes?
74 | * How do you delete data from a hash?
75 | * How do you add hashes together?
76 | * How do you list out all the keys or values?
77 | * How do you see if the hash contains a key or value?
78 | * What is a set?
79 |
80 | #### Dates and Times:
81 | * How do you get the current date and time?
82 | * How do you find just the Year? Month? Hour? Second? Weekday?
83 | * How do you create a `Time` specifically for 12/25/2013?
84 | * How do you find how many days have passed between two `Time`'s?
85 | * What's the difference between UTC and GMT and Local times?
86 | * How would you find out the time that was 100 seconds ago? 10 days ago?
87 |
88 | #### Other Random Stuff:
89 | * What is `nil`?
90 | * How do you check if something is `nil`?
91 | * What's the difference between `nil` and `blank` and `empty`?
92 | * Are the following `nil` or `empty`?
93 | * `" "`, `""`, `[]`, `[""]`, `{}`
94 | * What's the difference between `puts` and `p` and `print`?
95 | * What does `inspect` do?
96 | * What do `+=`, `-=`, `*=` and `/=` do?
97 | * What is parallel assignment?
98 | * What's the easiest way to swap two variables?
99 |
100 | ### Assignment
101 |
102 |
103 |
104 | 1. You should have already completed [Learn to Program](http://pine.fm/LearnToProgram/) in the Web Development 101 course to start with.
105 | 2. Do the full [Codecademy Introduction to Ruby section](http://www.codecademy.com/courses/ruby-beginner-en-d1Ylq/0/1) from their [Ruby Track](http://www.codecademy.com/tracks/ruby).
106 | 3. Read [Beginning Ruby](https://books.google.com/books?id=VCQGjDhhbn8C&lpg=PA27&pg=PA13#v=onepage&q&f=false) Chapter 2: `Programming == Joy: A Whistle Stop Tour of Ruby and Object Orientation`
107 | 4. Read [Beginning Ruby](https://books.google.com/books?id=VCQGjDhhbn8C&lpg=PA27&pg=PA31#v=onepage&q&f=false) Chapter 3: `Ruby's Building Blocks: Data, Expressions, and Flow Control` pages 29-46 (only the section on Numbers and Expressions and the section on Text and Strings)
108 | 5. Take a look at the [Ruby Date and Time explanation from TutorialsPoint](http://www.tutorialspoint.com/ruby/ruby_date_time.htm). No need to memorize all the Time Formatting Directives, just know what they are and where to find them.
109 | 6. Do this great little [Regex Tutorial](http://regexone.com/) and the example problems (should only take an hour or so)
110 | 7. Glance over this list of [Escape Characters](https://github.com/ruby/ruby/blob/trunk/doc/syntax/literals.rdoc#strings) in Ruby and keep it for future reference. You'll probably only end up using `\n` newlines and `\t` tabs.
111 | 8. For a deeper look at certain underserved pieces of the above material, check out these posts from Erik Trautman:
112 | 1. [Ruby Explained: Numbers, Operators and Expressions](http://www.eriktrautman.com/posts/ruby-explained-numbers-operators-and-expressions)
113 | 2. [Ruby Explained: Objects and Methods](http://www.eriktrautman.com/posts/ruby-explained-objects-and-methods)
114 | 3. [Ruby Explained: Strings](http://www.eriktrautman.com/posts/ruby-explained-strings)
115 | 4. [Ruby Explained: Arrays](http://www.eriktrautman.com/posts/ruby-explained-arrays)
116 | 5. [Ruby Explained: Hashes](http://www.eriktrautman.com/posts/ruby-explained-hashes)
117 | 6. [Ruby Explained: Dates and Times](http://www.eriktrautman.com/posts/ruby-explained-dates-and-times)
118 | 6. [Ruby Explained: Other Random Tidbits](http://www.eriktrautman.com/posts/ruby-explained-other-random-tidbits)
119 |
120 |
121 | ### Test Yourself
122 | Note: If you want to actually write and run your own Ruby code, you can either use IRB from the command line (type `irb` after the prompt), or run it from a script file using `$ ruby ./your_file_name_in_the_current_directory.rb`, or use the online editor at [repl.it](http://repl.it/languages/Ruby).
123 |
124 |
125 | 1. Make sure you can do the [Beginner Ruby Quiz #1](http://www.codequizzes.com/ruby/beginner/variables-strings-numbers) from [Code Quizzes](http://www.codequizzes.com/).
126 | 2. Make sure you go back up and look at all the questions from the "Learning Outcomes" section. See if you can do most of them without looking back through the text.
127 |
128 |
129 | ### Additional Resources
130 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
131 |
132 | * If you still don't understand certain topics or don't like my summary, look them up in the [Bastard's Book](http://ruby.bastardsbook.com/)
133 | * Read [Learn Ruby the Hard Way Chapters 1-5](http://ruby.learncodethehardway.org/book/ex3.html) for a basic treatment of numbers.
134 | * Read [Zetcode's Data Types section](http://zetcode.com/lang/rubytutorial/datatypes/) for a bit more depth on the subject.
135 | * [Alex Chaffee's brief writeup on Objects](http://codelikethis.com/lessons/learn_to_code/objects)
136 | * [Ruby Inheritance](http://rubylearning.com/satishtalim/ruby_inheritance.html)
137 | * Read [Zetcode's Strings section](http://zetcode.com/lang/rubytutorial/strings/) for an in-depth look at strings.
138 | * Read through (and watch the video) for this [Regular Expressions in Ruby](http://net.tutsplus.com/tutorials/ruby/ruby-for-newbies-regular-expressions/) explanation.
139 | * Read the [zetcode Arrays chapter](http://zetcode.com/lang/rubytutorial/arrays/) for some more in-depth knowledge. Don't worry too much where they talk about blocks or the `select`, `collect` and `map` methods, we'll cover that in a later section.
140 | * Read [Zetcode's Hashes section](http://zetcode.com/lang/rubytutorial/hashes/) for some more depth on hashes. Again, don't worry too much about `map` and other block-taking functions.
141 | * [Nil vs Empty vs Blank](http://stackoverflow.com/questions/885414/a-concise-explanation-of-nil-v-empty-v-blank-in-ruby-on-rails)
142 | * [p vs puts in Ruby](http://stackoverflow.com/questions/1255324/p-vs-puts-in-ruby)
143 | * [Ruby Cheat Sheet (pretty dense) from OverAPI](http://overapi.com/ruby)
144 |
--------------------------------------------------------------------------------
/ruby_programming/basic_ruby/lesson_how_this_course_will_work.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | In this unit you will learn Ruby, the language designed specifically with programmer happiness in mind. It's a healthy chunk of learning but, by the end of it all, you'll have built some pretty sweet projects including **Tic Tac Toe**, **Hangman**, **a real web server**, and even **Chess**. You'll be able to put together a **Twitter spambot** (that really spams!), save and open files, test out your code, separate your spaghetti code into nice modular classes, and even reproduce some basic algorithms and data structures for solving complex problems. *Basically, you're going to start feeling a whole lot more like a real programmer and that feeling will be justified.*
4 |
5 | Some people believe you can just dive right into Rails and start firing out websites. Rails is a framework built using Ruby and every piece of code in it is Ruby. When (not *if*) something in your project breaks, you'd better be able to debug it. And what happens when you want to stretch your wings and do something just a bit beyond what the vanilla tutorials show you how to do? The amount of time you'd spend googling your error messages and staring blankly at help docs was better spent learning Ruby. Despite this, we've offered the "cutting corners" path as an option below that gets you there faster.
6 |
7 | As you may gather, this is also where the real project work begins. Some of the early material will be fairly straightforward and will rely on simple exercises to help reinforce understanding. We'll learn using some Codecademy modules at first but the goal is for you to get a much deeper and more practical understanding of the material than that. As we get further along and into some of the more advanced topics, we'll be learning less and building more... just the way it should be. Let's get learning!
8 |
9 | ### Format
10 |
11 | Ruby's a big language so it's been broken up into smaller chunks to make it more digestible. The format should feel quite familiar to you since it's essentially the same as we used in Web Development 101.
12 |
13 | #### In each lesson:
14 |
15 | 1. We'll introduce the topic briefly and provide you with a list of things you should pay attention to.
16 | 1. You'll be asked to do readings, watch videos, do online courses or otherwise consume content to initially learn the material.
17 | 2. At the end of most lessons will be exercises to help you solidify your knowledge of the material.
18 | 3. Every few lessons you will be asked to build a larger project. These are best done with a friend.
19 | 2. Finally, we'll include additional helpful resources and other potentially useful tidbits at the end of each lesson.
20 |
21 |
22 | ### Two Paths Forward
23 |
24 | Everyone is coming into this with a different goal in mind, so to accommodate that, here's two options for your path forward:
25 |
26 | 1. **If you're just trying to race ahead and put up some Rails sites as fast as possible** (and worry about learning the fundamentals later), then your best bet is to first complete the Basic Ruby section, which uses primarily Codecademy as a resource, and then skip to the Rails course. Your knowledge won't be complete but you'll be in a pretty good spot to start from if you're in a hurry.
27 | 2. **If you're really looking for a solid, sustainable base of knowledge**, just stick to the normal roadmap. What we cover will give you a problem solving ability that you won't otherwise have. The projects, especially the final one, are worthy feathers in your cap that you can show off to any employer. We'll get you there and there really aren't any shortcuts in the long term.
28 |
29 | ### Our Primary "Textbooks"
30 |
31 | 1. [Codecademy.com](http://www.codecademy.com/tracks/ruby) has a lot of great introductory content to get you ramped into the Ruby language. You've already read [Chris Pine's Learn to Program](http://pine.fm/LearnToProgram/) in the Web Development 101 section for a good introduction, and the Codecademy stuff will overlap a bit and carry forward from there.
32 | 2. Peter Cooper's [Beginning Ruby](https://www.amazon.co.uk/Beginning-Ruby-Professional-Peter-Cooper/dp/1484212797) is a solid introduction to Ruby that covers pretty much the breadth of the language as you need to understand it. It's a bit outdated but Ruby hasn't changed a whole lot since then. The goal of this project is to move BEYOND Codecademy and other simple, free resources and get you building stuff on your own. This book will start covering some of the more intermediate/useful stuff that you'll need to know to do that.
33 |
34 | ### The (Free) Backup "Textbooks"
35 |
36 | Some things you just won't pick up right away or their coverage by main resources will fall short of your expectations. Luckily there are lots of options for places to shore up your understanding:
37 |
38 | 1. The best free online book: Dan Nguyen's [Bastard's Book of Ruby](http://ruby.bastardsbook.com/). Basically, if you don't like the content we've roped together, this is your resource to shore up your understanding.
39 | 1. Another free online book: Zed Shaw's [Learn Code the Hard Way](http://ruby.learncodethehardway.org/book/), an extension of his wildly popular Learn Python the Hard Way into Ruby. The downside is that the flow feels a bit choppy and parts aren't fully complete.
40 | 2. The other good book, available in the older edition online for free: [The "Pickaxe", or Programming Ruby 3rd Edition](https://pragprog.com/book/ruby4/programming-ruby-1-9-2-0). This, too, is a bit outdated.
41 |
42 | ### Okay, enough talk... Let's get started learning Ruby!
43 |
--------------------------------------------------------------------------------
/ruby_programming/computer_science/lesson_a_very_brief_intro_to_cs.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | You've learned how to build some cool stuff already and, frankly, you could probably make some decent websites without a crazy amount of additional formal education. However, just because you can write English at a grade school level doesn't mean you will be editing the New York Times anytime soon.
4 |
5 | In the world of programming, there's a difference between solving a problem the brute force way and solving a problem WELL. We touched on the first layer of this when we covered basic object-oriented programming and how you should break apart your code into well-organized chunks.
6 |
7 | If you assume those lessons were all about learning how to write good code, these next few lessons are going to be about training yourself to figure out the best code to write -- the most elegant solution to the problem at hand. It becomes particularly important whenever you start working with large data sets, like when your website becomes highly successful.
8 |
9 | We're taking a look at some more Computer Science-y concepts here because they are fundamental for a reason. Some problems require you to use tools beyond just arrays and iterators. You're going to build chess and it's not fundamentally difficult (it's just a rules-based game after all) but there are some tricks that you'll want to use to help you solve it. There's no sense reinventing the wheel when others have already figured out good methods for solving certain types of problems.
10 |
11 | If that doesn't get you interested, remember that this curriculum is meant to prepare you for life beyond the web page. If you're interested in applying for a job, you'll be asked questions that directly touch on some of this stuff. It's going to require you to put on your thinking cap (sorry, it had to happen sometime), but we won't be doing anything too crazy. We'll stick to the practical side of this material as opposed to getting too stuck in theory.
12 |
13 | ### Learning Outcomes
14 | Look through these now and then use them to test yourself after doing the assignment:
15 |
16 | * What is an algorithm?
17 | * What is pseudo-code?
18 |
19 | ### Assignment
20 |
21 |
22 | 1. Skim this [Introduction to Algorithms by David Malan](http://ed.ted.com/lessons/your-brain-can-solve-algorithms-david-j-malan) on TedEd to see how to think about algorithms.
23 | 2. Watch [What is an Algorithm?](https://youtu.be/e_WfC8HwVB8) on YouTube. for a more structured look at solving problems using algorithms.
24 | 3. Read [this Quora question about the importance of algorithms in web development](http://www.quora.com/Algorithms/What-is-the-importance-of-algorithms-in-web-development) to get some context for why we're going over this stuff.
25 |
26 |
27 | ### Additional Resources
28 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
29 |
30 | * [Wikipedia on Computer Science](http://en.wikipedia.org/wiki/Computer_science)
31 | * [Wikipedia on Algorithms](http://en.wikipedia.org/wiki/Algorithm)
32 | * [Map of Computer Science](https://youtu.be/SzJ46YA_RaA)
33 | * [What is pseudocode?](https://www.youtube.com/watch?v=Rg-fO7rDsds)
34 |
--------------------------------------------------------------------------------
/ruby_programming/computer_science/lesson_common_data_structures_algorithms.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | The basic idea of a **data structure** is to store data in a way that meets the needs of your particular application. You might be inclined to store a particular kind data in one giant array, but it would be rather time consuming to locate a specific value if you had a significant number and depth of items. So you need to look to other options.
4 |
5 | Depending on the application, there are a batch of other basic data structures available to help you out. The differences between them typically have to do with trade-offs between how long it takes to first populate the structure, how long it takes to add or find elements, and how large the structure is in memory.
6 |
7 | We'll save the specifics of data structures for more computer-science-oriented courses, but this introduction should again expand your toolbox slightly so you can identify and solve certain problems where plain old Arrays, Hashes and Sets don't quite cut it. New structures and strategies will be particularly relevant, for instance, when you're trying to search through a large batch of data for a particular value or plan out a strategy several moves in advance.
8 |
9 | You've already had a brief introduction to **algorithms** over some of the other lessons and you even got to write your own Merge Sort algorithm in the last project. You'll find that sorting algorithms are quite common. Another major area for algorithms is in search, where milliseconds count. When you're searching through enormous troves of data, the quality of your search algorithm is incredibly important. Traversing a data tree looking for a particular element is a related problem that's common in data intensive applications.
10 |
11 | Luckily for you, these complex algorithmic problems have all been solved many times in the past. Understanding *how* they are solved will give you some great tools to apply to other (similar) problems on your own. Algorithms are really just ways of solving problems (like this) systematically. In this brief introduction, we'll focus on a couple of algorithms that you may run into when coding on your own -- breadth-first-search and depth-first-search.
12 |
13 | ### Learning Outcomes
14 | Look through these now and then use them to test yourself after doing the assignment:
15 |
16 | * What is a data structure?
17 | * What is a stack?
18 | * What is a queue?
19 | * What's the difference between a stack and a queue?
20 | * What is a stack useful for?
21 | * What is a queue useful for?
22 | * What's the best way to implement stacks and queues in Ruby (hint: think simple)?
23 | * Why bother having many different search algorithms?
24 | * What is breadth-first-search (BFS)?
25 | * What is depth-first-search (DFS)?
26 | * What situations would you want to use BFS?
27 | * What situations would you want to use DFS instead?
28 | * When would BFS be impractical?
29 |
30 | ### Assignment
31 |
32 |
33 | 1. Glance over the [Wikipedia entry on Data Structures](http://en.wikipedia.org/wiki/Data_structure) for a high level overview of things.
34 | 2. Learn about Queues and Stacks by watching [this video](https://www.youtube.com/watch?v=6QS_Cup1YoI)
35 | 3. Learn about binary search trees by watching [this video](https://www.youtube.com/watch?v=T98PIp4omUA) from Harvard's CS50 on Youtube.
36 | 4. Learn about basic algorithms from Coursera's Algorithms course in [this video](http://www.youtube.com/watch?v=u2TwK3fED8A). The first 10 minutes are really the meat of the introduction to algorithms, the rest gets more mathematical (if you're so inclined).
37 | 5. Read the [Gentle Introduction to Algorithms for Web Developers](http://www.giocc.com/a-gentle-introduction-to-algorithms-for-web-developers.html) for another basic look at what algorithms are.
38 | 5. Finally, learn about Depth First Search and Breadth First Search from this series of videos on YouTube:
39 | * [Binary Tree Traversal](https://www.youtube.com/watch?v=9RHO6jU--GU)
40 | * [Level Order Traversal](https://www.youtube.com/watch?v=86g8jAQug04) (aka Breadth First)
41 | * [Pre, In, and Post Order Traversal](https://www.youtube.com/watch?v=gm8DUJJhmY4) (aka Depth First)
42 |
43 |
44 | ### Additional Resources
45 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
46 |
47 | * [Khan Academy's great Algorithms Course](https://www.khanacademy.org/computing/computer-science/algorithms)
48 | * [Stanford's Coursera 4-Part Algorithm Course](https://www.coursera.org/specializations/algorithms)
49 | * [Visualizing Algorithms from Mike Bostock](http://bost.ocks.org/mike/algorithms/)
50 | * [Another free course on algorithms by Udacity](https://www.udacity.com/course/cs215)
51 | * [A brief note on putting Sorting, Tries and Heaps into Ruby, by Ilya Grigorik](http://www.igvita.com/2009/03/26/ruby-algorithms-sorting-trie-heaps/)
52 |
--------------------------------------------------------------------------------
/ruby_programming/computer_science/lesson_recursion.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | Recursion is the idea that a function calls itself. Pretty simple, right? It's used to take a big problem and start breaking it down into smaller and smaller pieces ("Divide and Conquer") and continuing to feed their solutions back into the original function until some sort of answer is achieved and the whole chain unwinds.
4 |
5 | From the [Wikipedia entry on Divide and Conquer Algorithms](http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm):
6 |
7 | > In computer science, divide and conquer (D&C) is an important algorithm design paradigm based on multi-branched recursion. A divide and conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same (or related) type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem.
8 |
9 | There's also a right and wrong way to use recursion. The fact is, any problem you can solve recursively you can also solve using the iterators that you know and love. If you find yourself saying "why didn't I just use a `while` loop here?" then you probably should have. You won't often end up using a recursive solution to a problem, but you should get a feel for when it might be a good idea. Some problems also break down into far too many pieces and totally overwhelm your computer's memory. There's a balance.
10 |
11 | In this brief lesson, you'll get a chance to learn more about when and how to use recursion and then in the next project you will get the chance to apply some of that (since it probably won't really stick until you've had a chance to try it).
12 |
13 | ### learning Outcomes
14 | Look through these now and then use them to test yourself after doing the assignment
15 |
16 | * Why is recursion a useful technique for solving a big problem?
17 | * What are the limitations of using recursive solutions?
18 | * What types of problems are more suited for simple loops than recursion?
19 | * What is meant by "recursive depth?"
20 | * What is a "stack overflow" (the concept, not the website)?
21 | * Why is that relevant to a recursive problem?
22 |
23 | ### Assignment
24 |
25 |
26 | 1. Read the [Chapter on Recursion](http://ruby.bastardsbook.com/chapters/recursion/) in the Bastards Book of Ruby by Dan Nguyen
27 | 2. Watch this [Video on Recursion](http://vimeo.com/24716767) by Joshua Cheek but only until minute 17:45! (don't want to give away the project...)
28 | 3. Read the ["Implementation Issues" section of the wiki article](http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm#Implementation_issues) to get an overview of some of the limitations of recursion.
29 |
30 |
31 | ### Test Yourself
32 |
33 |
34 | 1. Complete the [Code Quiz](http://www.codequizzes.com/computer-science/beginner/recursion) on Recursion.
35 |
36 |
37 | ### Additional Resources
38 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
39 |
40 |
41 | * ["What is Ruby Recursion and How Does It Work?"](http://stackoverflow.com/questions/6418017/what-is-ruby-recursion-and-how-does-it-work) on Stack Overflow
42 | * [Efficient Recursion from U of Alberta](http://webdocs.cs.ualberta.ca/~holte/T26/efficient-rec.html)
43 | * [Natashatherobot's blog post on Recursion in Ruby](http://natashatherobot.com/recursion-factorials-fibonacci-ruby/)
44 | * [Functional Programming Techniquest with Ruby post](http://www.sitepoint.com/functional-programming-techniques-with-ruby-part-iii/), which covers recursion at the top
45 |
--------------------------------------------------------------------------------
/ruby_programming/computer_science/project_linked_lists.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | In Computer Science one of the most basic and fundamental data structures is the
4 | linked list, which functions similarly to an array. The principal benefit of a linked
5 | list over a conventional array is that the list elements can easily be inserted or
6 | removed without reallocation of any other elements.
7 |
8 | In some programming languages the size of an array is a concern and one of the ways
9 | to overcome that problem and allow dynamically allocated data is using linked lists.
10 |
11 | Luckily in **Ruby** arrays aren't limited to a certain size, so you don't have to think
12 | about overcoming that limitation.
13 |
14 | So if array size is not a limitation in Ruby, are linked lists really necessary?
15 | The short answer to that is *no*; however, it's the simplest of the dynamic data
16 | structures and it will give you a solid foundation, so you can understand more
17 | complex data structures like graphs and binary trees with more ease.
18 |
19 | ### Structure of a Linked List
20 | A *linked list* is a linear collection of data elements called nodes that "point"
21 | to the next node by means of a pointer.
22 |
23 | Each node holds a single element of data and a link or pointer to the next node in the list.
24 |
25 | A head node is the first node in the list, a tail node is the last node in the list. Below is a basic representation of a linked list:
26 |
27 | `[ NODE(head) ] -> [ NODE ] -> [ NODE(tail) ] -> nil`
28 |
29 | For a more thorough explanation, use these resources:
30 |
31 | 1. [Linked Lists in Plain English](https://www.youtube.com/watch?v=oiW79L8VYXk)
32 | 2. [Linked Lists, Ruby's Missing Data Structure](https://www.sitepoint.com/rubys-missing-data-structure/)
33 | 3. [A more verbose explanation with plenty of diagrams](http://www.cs.cmu.edu/~adamchik/15-121/lectures/Linked%20Lists/linked%20lists.html)
34 |
35 |
36 | ### Assignment
37 |
38 |
39 | You will need two classes:
40 |
41 | 1. `LinkedList` class, which will represent the full list.
42 | 2. `Node` class, containing a `#value` method and a link to the `#next_node`, set both as `nil` by default.
43 |
44 |
45 | Build the following methods in your linked list class:
46 |
47 | 1. `#append` adds a new node to the end of the list
48 | 2. `#prepend` adds a new node to the start of the list
49 | 3. `#size` returns the total number of nodes in the list
50 | 4. `#head` returns the first node in the list
51 | 5. `#tail` returns the last node in the list
52 | 6. `#at(index)` returns the node at the given index
53 | 7. `#pop` removes the last element from the list
54 | 8. `#contains?` returns true if the passed in value is in the list and otherwise returns false.
55 | 9. `#find(data)` returns the index of the node containing data, or nil if not found.
56 | 10. `#to_s` represent your LinkedList objects as strings, so you can print them out and preview them in the console.
57 | The format should be: `( data ) -> ( data ) -> ( data ) -> nil`
58 |
59 | ### Extra Credit
60 |
61 | 1. `#insert_at(index)` that inserts the node at the given index
62 | 2. `#remove_at(index)` that removes the node at the given index. (You will need to update the links of your nodes in the list when you remove a node.)
63 |
64 |
65 | ### Student Solutions
66 | Submit a link below to this [file](https://github.com/TheOdinProject/ruby_course/blob/master/ruby_programming/computer_science/project_linked_lists.md) on the ruby course github repo with your files in it by using a pull request. See the section on [Contributing](http://github.com/TheOdinProject/curriculum/blob/master/contributing.md) for how.
67 |
68 | * Add your solution below this line!
69 | * [Mohamed Elattar's Solution](https://github.com/mohamed-elattar/linked-list)
70 | * [brendan tang's solution](https://github.com/brndntng/linked_list)
71 | * [prw001's Solution](https://github.com/prw001/linked_list)
72 | * [Max Garber's Solution](https://github.com/bubblebooy/miscellaneous-exercises/blob/master/Linked%20List.rb)
73 | * [Malaika (Mic) Solution](https://github.com/malaikaMI/Link_list)
74 | * [Sherman Bowling's solution](https://github.com/janus0/top_course_work/tree/master/ruby/project_linked_list)
75 | * [Nathan Sherburne's solution](https://github.com/nathansherburne/ruby_practice/blob/master/data_structures/linked_list.rb)
76 | * [Javier Machin's solution](https://github.com/Javier-Machin/Linked_list/blob/master/linked_list.rb)
77 | * [Btreim's solution](https://github.com/btreim/ruby/blob/master/linked_list.rb)
78 | * [0zra's solution](https://github.com/0zra/linkedlist/blob/master/linkedlist.rb)
79 | * [Demo318's solution (with extra credit)](https://github.com/Demo318/ruby_linked_lists)
80 | * [mtizim's solution (with extra credit)](https://github.com/mtizim/odin_projects/blob/master/ruby/linkedlists.rb)
81 | * [Isil Donmez's solution](https://github.com/isildonmez/linked_lists/blob/master/linked_lists.rb)
82 | * [Bruno Parga's solution](https://github.com/brunoparga/odinproject/blob/master/Ruby/linkedlist.rb)
83 | * [Jmooree30's solution](https://github.com/jmooree30/Linked-list.git)
84 | * [Andrew's solution](https://github.com/andrewr224/Linked-Lists)
85 | * [Jason McKee's solution](https://github.com/jttmckee/odin-project-ruby/tree/master/LinkedList)
86 | * [Jonathan Yiv's solution](https://github.com/JonathanYiv/linked_list)
87 | * [Roland Studer's solution](https://github.com/RolandStuder/odin_project_solutions/tree/master/linked_lists)
88 | * [justinckim3's solution](https://github.com/justinckim3/linked_list/blob/master/linked_list.rb)
89 | * [Kasey Z's Solution (with extra credit)](https://github.com/kasey-z/TOP-solutions/blob/master/linked_lists/linked_lists.rb)
90 | * [thisisned's solution](https://github.com/thisisned/linked_list/blob/master/linked_list.rb)
91 | * [SadieD's solution](https://github.com/SadieD/linked_lists)
92 | * [Clayton Sweeten's Solution](https://github.com/cjsweeten101/OdinProjects/tree/master/linked_list)
93 | * [holdercp's solution](https://github.com/holdercp/linked_lists)
94 | * [Webdev-burd's solution](https://github.com/webdev-burd/linked_list)
95 | * [Jfonz412's solution](https://github.com/jfonz412/computer_science/blob/master/linked_lists.rb)
96 | * [xavier solution (+ extra)](https://github.com/nxdf2015/odin-linked-lists/blob/master/linked_list.rb)
97 | * [Ovsjah Schweinefresser's Solution](https://github.com/Ovsjah/linked_lists)
98 | * [Oleh Sliusar's solution](https://github.com/OlehSliusar/linked_lists)
99 | * [Nikolay Dyulgerov's solution](https://github.com/NicolayD/ruby-data-structures/blob/master/linked_list.rb)
100 | * [mindovermiles262's Solution](https://github.com/mindovermiles262/linked-list)
101 | * [theghall's solution](https://github.com/theghall/linked-list.git)
102 | * [yilmazgunalp's solution with extra](https://github.com/yilmazgunalp/linked_list)
103 | * [Ayushka's solution](https://github.com/ayushkamadji/ruby_linked_list/blob/master/lib/LinkedList.rb)
104 | * [ToTenMilan's solution with extra](https://github.com/ToTenMilan/the_odin_project/tree/master/ruby/linked_list)
105 | * [Raiko's Solution (with extra credit)](https://github.com/Cypher0/linked_lists/blob/master/linked_list.rb)
106 | * [Nicolas Amaya's solution (with extra)](https://github.com/nicoasp/TOP---Ruby-Linked-Lists)
107 | * [nmac's Solution](https://github.com/nmacawile/LinkedList)
108 | * [John Phelps's Solution (+extra)](https://github.com/jphelps413/odin-ruby/blob/master/linked-lists/linked_list.rb)
109 | * [Jib's Solution (with extra credit)](https://github.com/NuclearMachine/OdinTasks/tree/master/LinkedLists)
110 | * [Stefan (Cyprium)'s solution](https://github.com/dev-cyprium/linked-lists-ruby/)
111 | * [Cody Loyd's solution (with tests and extra credit)](https://github.com/codyloyd/linked_list)
112 | * [Miguel Herrera's solution](https://github.com/migueloherrera/linked-lists)
113 | * [KrakenHH's solution](https://github.com/KrakenHH/ruby/tree/master/algorithms/linked_list)
114 | * [Shala Qweghen's solution](https://github.com/ShalaQweghen/linked_list)
115 | * [John Connor's solution](https://github.com/jacgitcz/linked_list)
116 | * [Earth35's solution](https://github.com/Earth35/linked-list/blob/master/linked_list.rb)
117 | * [Oscar Y.'s solution](https://github.com/mysteryihs/ruby_projects/blob/master/linked_list.rb)
118 | * [Amrr Bakry's solution - with extra credit](https://github.com/Amrrbakry/learning_ruby/blob/master/LinkedList/linked_list.rb)
119 | * [Jean Merlet's solution](https://github.com/jeanmerlet/linked_lists/blob/master/linked_list.rb)
120 | * [Manu Phatak's HIGH ENERGY solution](https://github.com/bionikspoon/ruby_linked_list)
121 | * [fugumagu's solution with extra credit](https://github.com/fugumagu/the_odin_project/tree/master/linked_list)
122 | * [Sasho's solution /w extra credit](https://github.com/sashoa/the-odin-project/tree/master/project-linked-lists)
123 | * [Austin's solution with extra credit](https://github.com/CouchofTomato/algorithm/blob/master/linked_list.rb)
124 | * [Jiazhi Guo's solution (with extra credit)](https://github.com/jerrykuo7727/linked_lists)
125 | * [Dan Hoying's solution (with extra credit)](https://github.com/danhoying/linked_lists)
126 | * [Chris Chambers' solution (with extra credit)](https://github.com/chrisgchambers/ruby_exercies/blob/master/linked_list/linked_list.rb)
127 | * [Jorrit Luimers' (Voodoo Woodoo) solution](https://github.com/voodoowoodoo/ruby_linked_lists)
128 | * [Francisco Carlos's solution (with extra credit)](https://github.com/fcarlosdev/the_odin_project/tree/master/linked_lists)
129 | * [Loris Aranda's solution (with extra credit)](https://github.com/LorisProg/ruby-linked_lists)
130 | * [at0micr3d's solution (with extra credit)](https://github.com/at0micr3d/linked_list)
131 | * [Eric M's solution (with extra credit)](https://github.com/em77/linked_list)
132 | * [Clint's solution (extra cred)](https://github.com/tholymap/OdinLinkedList)
133 | * [Dylan's solution (with extra credit)](https://github.com/resputin/the_odin_project/blob/master/Ruby/linklist/linklist.rb)
134 | * [David Chapman's solution (with extra credit)](https://github.com/davidchappy/odin_training_projects/tree/master/linked_lists)
135 | * [Leonard Soai-Van solution](https://github.com/leosoaivan/TOP_compsci)
136 | * [Anthony Vumbaca's solution (with extra credit)](https://github.com/tvumbaca/linked_lists/blob/master/linked_list.rb)
137 | * [Jerry Gao's tryhard solution](https://github.com/blackwright/odin/tree/master/ruby_linked_list)
138 | * [Marcus' solution (with extra credit)](https://github.com/nestcx/odin_comp_sci/blob/master/linked_list.rb)
139 | * [Mateusz Staszczyk's](https://github.com/sleaz0id/LinkedList)
140 | * [Sophia Wu's solution (with extra credit)](https://github.com/SophiaLWu/project-linked-lists)
141 | * [Samuel Langenfeld's solution](https://github.com/SamuelLangenfeld/linked_list)
142 | * [Braydon Pacheco's solution](https://github.com/pacheeko/linked_lists/blob/master/linked_lists.rb)
143 | * [Robert Szabo's solution](https://github.com/Siker001/the_odin_project_exercises/blob/master/ruby/linked_lists/linked_list.rb)
144 | * [jeff1st's solution](https://github.com/jeff1st/linked_list)
145 | * [Noah Prescott's solution](https://github.com/npresco/top/tree/master/linked_list)
146 | * [Cody Buffaloe's solution](https://github.com/CodyLBuffaloe/Linked_Lists)
147 | * [Daniel Varcas aka d-zer0's solution](https://github.com/d-zer0/linked_list/blob/master/linked_list.rb)
148 | * [Zach Beaird's solution (with extra credit)](https://github.com/zbbeaird89/Linked-List)
149 | * [EMuchynski's solution](https://github.com/EMuchynski/linked_lists)
150 | * [Luján Fernaud's solution](https://github.com/lujanfernaud/ruby-linked-list)
151 | * [Jason Dancocks' solution](https://github.com/JasonDancocks/Ruby/tree/master/linkedlists)
152 | * [Anistor86's solution](https://github.com/anistor86/linked_list)
153 | * [James Redux's solution](https://github.com/Jamesredux/linked_list)
154 | * [Oliver Curting's solution (with extra credit)](https://github.com/Curting/linked_lists)
155 | * [Alex's solution](https://github.com/alexcorremans/linked_list)
156 | * [HSaad's solution](https://github.com/HSaad/linked-lists)
157 | * [Scott McKell's Solution:](https://github.com/zottwickel/linked_list.git)
158 | * [Punnadittr's Solution:](https://github.com/punnadittr/linked_list/blob/master/linked_lists.rb)
159 | * [Agon Idrizi's Solution:](https://github.com/AgonIdrizi/Recursion/blob/master/linked_list.rb)
160 | * [Areeba's Solution](https://github.com/AREEBAISHTIAQ/LinkedLists/blob/master/linkedlist.rb)
161 | * [dmarkiewicz's Solution](https://github.com/dmarkiewicz/the-odin-project/tree/master/Ruby/Linked-list)
162 | * [Felipe Parreira's Solution](https://github.com/FelipeParreira/TheOdinProject/blob/master/ruby-programming/a-bit-of-CS/linked_lists/linked-list.rb)
163 | * [mojotron's Solution](https://github.com/mojotron/linked-lists/blob/master/linked_list_class.rb)
164 |
165 |
--------------------------------------------------------------------------------
/ruby_programming/conclusion/lesson_conclusion.md:
--------------------------------------------------------------------------------
1 | You did it! Ruby is conquered. You're now a ninja.... okay, that's a bit hyperbolic but the fact is that you now know more than enough Ruby to take on Rails like a Boss. And, actually, the real secret is that the hard part is over. Getting to this point is the most difficult part of the learning curve.
2 |
3 | Sure, you've still got plenty to learn, but the real conceptual leaps have already been made. You can think like a programmer now and should be able to figure out how to appropriately Google for pretty much anything you don't already know.
4 |
5 | If you know Ruby, the world is sort of opened up for you. Want to learn Python? That would be a whole lot easier now. Nervous about Rails? Don't be. Rails is just Ruby that's been packaged up to do lots of stuff for you. With what you know, you'll have a much easier time "seeing the matrix" and understanding what Rails is up to. Even Javascript should make a whole lot more sense to you once we get back to it.
6 |
7 | So that's it, you're more than ready to to go ahead and take on Rails. **Congratulations!!!**
8 |
9 | ### Additional Resources
10 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
11 |
12 | * [Ruby Best Practices book by Gregory Brown](http://it-ebooks.info/book/178/).
13 | * [Why Ruby and Python are different](http://stackoverflow.com/questions/1113611/what-does-ruby-have-that-python-doesnt-and-vice-versa?rq=1)
14 | * [exercism.io](http://exercism.io/), a site where you can grow and improve your ability to **write code** by **reading others' code** and **commenting** on it.
15 |
--------------------------------------------------------------------------------
/ruby_programming/conclusion/project_ruby_final.md:
--------------------------------------------------------------------------------
1 | ### You've come a long way. Now it's time to prove how much you've learned.
2 |
3 | Chess is a classic game that appears very complicated at first but can be broken down into logical steps that make it a great Ruby capstone project. If you've never played, be sure to read up on the rules (see the [Wikipedia Page](http://en.wikipedia.org/wiki/Chess)) first.
4 |
5 | The problem specification is deliberately sparse for this, your final project of Ruby -- it's up to you to attack the problem with very little prior information or structure, which is good practice for real world programming challenges. You have all the tools you need. You already did a lot of the heavy thinking in the [Knight's Travails project](https://www.theodinproject.com/courses/ruby-programming/lessons/data-structures-and-algorithms).
6 |
7 | The main difference is that this problem has the broadest scope of anything you've done yet. The keys here will be thinking it through logically ahead of time and maintaining a disciplined workflow. It'll be much easier on you if you're able to stay organized and break it down into components that you can tackle one by one.
8 |
9 | This is a great project to have as a part of your portfolio going forward because it shows you can take on something with a lot of different components to it.
10 |
11 | ### Assignment
12 |
13 |
14 | 1. **Build a command line Chess game where two players can play against each other.**
15 | 2. The game should be properly constrained -- it should prevent players from making illegal moves and declare check or check mate in the correct situations.
16 | 3. Make it so you can save the board at any time (remember how to serialize?)
17 | 2. Write tests for the important parts. You don't need to TDD it (unless you want to), but be sure to use RSpec tests for anything that you find yourself typing into the command line repeatedly.
18 | 3. Do your best to keep your classes modular and clean and your methods doing only one thing each. This is the largest program that you've written, so you'll definitely start to see the benefits of good organization (and testing) when you start running into bugs.
19 | 4. Have fun! Check out the [unicode characters](http://en.wikipedia.org/wiki/Chess_symbols_in_Unicode) for a little spice for your gameboard.
20 | 5. (Optional extension) Build a very simple AI computer player (perhaps who does a random legal move)
21 |
22 |
23 | ### Student Solutions
24 | Submit a link below to this [file](https://github.com/TheOdinProject/ruby_course/blob/master/ruby_programming/conclusion/project_ruby_final.md) on the ruby course github repo with your files in it by using a pull request. See the section on [Contributing](http://github.com/TheOdinProject/curriculum/blob/master/contributing.md) for how.
25 |
26 | * Add your solution below this line!
27 | * [prw001's solution](https://github.com/prw001/chess)
28 | * [Max Garber's solution](https://github.com/bubblebooy/TOP-chess)
29 | * [Btreims's solution](https://github.com/btreim/chess)
30 | * [Javier Machin's solution](https://github.com/Javier-Machin/Chess_Ruby)
31 | * [0zra's solution](https://github.com/0zra/chess)
32 | * [Isil Donmez's solution](https://github.com/isildonmez/chess)
33 | * [Ovsjah Schweinefresser's solution](https://github.com/Ovsjah/ruby_final_project)
34 | * [Andrew's solution](https://github.com/andrewr224/chess)
35 | * [Jmooree30's Solution](https://github.com/jmooree30/Chess.git)
36 | * [Phil's Solution(javascript)](https://github.com/pip36/j_chess) - [View in Browser](https://pip36.github.io/j_chess)
37 | * [Jonathan Yiv's solution](https://github.com/JonathanYiv/chess)
38 | * [Kasey Z's solution](https://github.com/kasey-z/chess_game/tree/master/chess_game)
39 | * [Clayton Sweeten's solution](https://github.com/cjsweeten101/OdinProjects/tree/master/chess)
40 | * [Raiko's solution](https://github.com/Cypher0/chess)
41 | * [adsy430's solution](https://github.com/adampal/ruby_chess)
42 | * [holdercp's solution](https://github.com/holdercp/chess)
43 | * [Nikolay Dyulgerov's solution](https://github.com/NicolayD/ruby-chess)
44 | * [jfonz412's solution](https://github.com/jfonz412/chess)
45 | * [nmac's solution](https://github.com/nmacawile/chess)
46 | * [Ayushka's solution](https://github.com/ayushkamadji/ruby_chess)
47 | * [Orlando's solution](https://github.com/orlandodan14/chess_game)
48 | * [Austin's & Leonard's solution](https://github.com/leosoaivan/TOP_chess)
49 | * [Nicolas Amaya's solution](https://github.com/nicoasp/TOP---Ruby-Final-Project/tree/master)
50 | * [Aleksandar's solution](https://github.com/rodic/RubyChess)
51 | * [Donald's solution](https://github.com/donaldali/Chess)
52 | * [TomTom's solution](https://github.com/tim5046/projectOdin/tree/master/Ruby/FinalProject)
53 | * [Hawkeye's solution](https://github.com/Hawkeye000/command-line-chess)
54 | * [Sergio Ribeiro's solution](https://github.com/serg1o/Chess)
55 | * [Marina Sergeyeva's solution](https://github.com/imousterian/OdinProject/tree/master/Project2_9_Final_Ruby_Chess)
56 | * [Kate McFaul's solution](https://github.com/craftykate/odin-project/tree/master/Chapter_03-Advanced_Ruby/chess)
57 | * [Dominik Stodolny's solution](https://github.com/dstodolny/chess)
58 | * [AtActionPark's solution](https://github.com/AtActionPark/odin_chess)
59 | * [Dan Hoying's solution](https://github.com/danhoying/chess)
60 | * [PiotrAleksander's solution](https://github.com/PiotrAleksander/Ruby/tree/master/Szachy)
61 | * [Sander Schepen's solution](https://github.com/schepens83/theodinproject.com/tree/master/ruby/project16--final-chess)
62 | * [Florian Mainguy's solution](https://github.com/florianmainguy/theodinproject/tree/master/ruby/chess)
63 | * [srashidi's solution](https://github.com/srashidi/Ruby_Final_Project/tree/master/chess)
64 | * [bskillings's solution](https://github.com/bskillings/Odin-Ruby-Final-Chess)
65 | * [Luke Walker's solution](https://github.com/ubershibs/ruby-programming/tree/master/chess)
66 | * [Tomasz Kula's solution](https://github.com/zetsnotdead/chess_ruby)
67 | * [Scott Bobbitt's solution](https://github.com/sco-bo/chess)
68 | * [Miguel Herrera's solution](https://github.com/migueloherrera/chess)
69 | * [Max Gallant's solution](https://github.com/mcgalcode/Ruby/tree/master/Chess)
70 | * [noobling's solution](https://github.com/TopOneOfTopOne/CLI_chess)
71 | * [Sahil Agarwal's solution](https://github.com/sahilda/the_odin_project/tree/master/rubyChess)
72 | * [James Brooks's solution](https://github.com/jhbrooks/chess)
73 | * [Cyprium (Stefan)'s solution](https://github.com/dev-cyprium/chess)
74 | * [Earth35's solution](https://github.com/Earth35/chess)
75 | * [Shala Qweghen's solution](https://github.com/ShalaQweghen/final)
76 | * [Jiazhi Guo's solution](https://github.com/jerrykuo7727/chess)
77 | * [DV's solution](https://github.com/dvislearning/chess)
78 | * [at0micr3d's solution](https://github.com/at0micr3d/ruby_chess)
79 | * [Dylan's solution](https://github.com/resputin/the_odin_project/blob/master/Ruby/final/lib/chess_single_array.rb)
80 | * [David Chapman's solution](https://github.com/davidchappy/odin_training_projects/tree/master/chess)
81 | * [Jerry Gao's solution](https://github.com/blackwright/odin/tree/master/ruby_chess)
82 | * [Samuel Langenfeld's solution](https://github.com/SamuelLangenfeld/Chess)
83 | * [Sophia Wu's solution](https://github.com/SophiaLWu/chess)
84 | * [Braydon Pacheco's solution](https://github.com/pacheeko/chess)
85 | * [John Connor's solution](https://github.com/jacgitcz/chessfinal)
86 | * [Kyle Thomson's solution](https://github.com/idynkydnk/chess)
87 | * [Jonathan Marks's solution](https://github.com/johnjmarks4/Chess)
88 | * [Luján Fernaud's solution](https://github.com/lujanfernaud/ruby-chess)
89 | * [Francisco Carlos's solution](https://github.com/fcarlosdev/the_odin_project/tree/master/chess_game)
90 | * [Bruno Parga's solution](https://github.com/brunoparga/chess)
91 | * [Kusnierewicz solution](https://github.com/Kusnierewicz/Chess-game)
92 | * [Zach Beaird's solution](https://github.com/zbbeaird89/Chess)
93 | * [Matthew King's solution](https://github.com/thewmking/ruby-chess)
94 | * [Jamesredux's solution](https://github.com/Jamesredux/chess)
95 | * [Punnadittr's solution](https://github.com/punnadittr/chess)
96 |
97 | ### Additional Resources
98 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
99 |
100 | * [Illustrated rules of Chess](http://www.chessvariants.org/d.chess/chess.html)
101 | * [A series of hints from RubyQuiz](http://rubyquiz.com/quiz35.html), where this was one of their challenges. You don't need these. Resist the temptation!
102 |
--------------------------------------------------------------------------------
/ruby_programming/git/lesson_a_deeper_look_at_git.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | Hopefully you've been using the basic Git commands to create repositories and push your code up to Github. If not, you've got a bit of catching up to do but don't worry.
4 |
5 | In any case, Git is a crucial skill to have whether you're a professional web developer or just a hobbyist who needs to back up your code base. It's the "save" button on steroids and it allows giant teams of developers to collaborate. There really aren't all that many commands for you to learn either, but sometimes the real difficulty of it comes from visualizing in your head what it's actually doing.
6 |
7 | In this lesson, we'll dive deeper than just the `$ git add .` and `$ git commit` and `$ git push` commands you've mostly been using. Maybe you've had the dubious pleasure of getting a merge conflict when you tried to pull or push changes. Maybe you're just curious how multiple developers can work on a single code base at the same time. Either way, this section should help you take the first steps towards expanding your Git toolkit and understanding what's actually going on under the hood with Git.
8 |
9 | It's important to take a look at this stuff before getting any deeper into things because the project work is becoming more and more complex so using a disciplined Git workflow is no longer optional. The axiom used to be "save early and often" and now it's "commit early and often". Hopefully, after you've finished this lesson you will feel much more comfortable with the basics and at least know what to Google if you'd like to do more.
10 |
11 | We'll begin by reading some things that are probably review from [Web Development 101](https://www.theodinproject.com/courses/web-development-101/lessons/introduction-to-git) but, if you're like most people, you could benefit from a refresher. We'll then dive deeper into topics that are relevant so you can use git for a more effective workflow, whether you're just working on your own project or trying to bring in collaborators as well.
12 |
13 |
14 | ### Learning Outcomes
15 | Look through these now and then use them to test yourself after doing the assignment:
16 |
17 | * How do you amend a commit message that you just messed up?
18 | * How do you view the history of your most recent commits?
19 | * What are two different uses for `$ git checkout`?
20 | * How do you undo a recent commit?
21 | * What are branches?
22 | * How do you create a new branch to work on?
23 | * How do you push that (non-master) branch up to Github?
24 | * How do you merge the changes from your new branch into the master branch again?
25 | * Why is working with feature branches useful?
26 | * What is the difference between using `$ git merge` and `$ git rebase`? (hint: history)
27 | * What is the difference between a "remote" and your local repo?
28 | * How do you add your Github repo as the remote?
29 |
30 | ### Assignment
31 |
32 | **Note:** *Subversion* (SVN) was the widely used version control system prior to Git (and is still widely used in larger corporations) and that's why many of the readings below will reference it. Just read the very top two sections of [this chapter from git-scm](http://git-scm.com/book/en/Git-and-Other-Systems-Git-and-Subversion) if you'd like a slightly better explanation.
33 |
34 |
35 | 1. If you haven't had the chance to do so, go through the [Web Development 101 Git Basics section](https://www.theodinproject.com/courses/web-development-101/lessons/introduction-to-git).
36 | 2. If you're still feeling a bit shaky, look at [Setting up a Repository](https://www.atlassian.com/git/tutorials/setting-up-a-repository), [Saving Changes](https://www.atlassian.com/git/tutorials/saving-changes), and [Inspecting a Repository](https://www.atlassian.com/git/tutorials/inspecting-a-repository) from Atlassian.
37 | 3. Read the section on [Undoing Changes](https://www.atlassian.com/git/tutorials/undoing-changes) from the same site.
38 | 4. Read about [Using Feature Branches](https://www.atlassian.com/git/tutorials/comparing-workflows#feature-branch-workflow) and then look at how it fits into a real workflow in [this section](/courses/ruby-programming/lessons/using-git-in-the-real-world). (This takes you to the next lesson. Read through the workflow presented there but don't do the assignment yet, then go back to it after you've finished this lesson)
39 | 5. Take a look at [Rewriting Git History](https://www.atlassian.com/git/tutorials/merging-vs-rebasing) to understand how Rebasing works. There's a lot of debate out there about whether it's best to use a "Merge" or "Rebase" based workflow. We'll stick with merge because it's a bit more straightforward and the errors can be a bit easy to get over, but you should be aware of rebasing as an alternative type of flow.
40 | 6. Read about working with [Remote Repositories](https://www.atlassian.com/git/tutorials/syncing), which should mostly be familiar to you by now.
41 | 7. Layer onto your knowledge a bit deeper by reading [Pro Git chapters 2 and 3](http://git-scm.com/book).
42 |
43 |
44 | ### Additional Resources
45 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
46 |
47 | * Watch [Get Going from Pro Git](http://git-scm.com/video/get-going) if you'd like a refresher of things.
48 | * Read [Git Cheat Sheet](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) if you need a reference sheet.
49 |
--------------------------------------------------------------------------------
/ruby_programming/git/lesson_using_git_in_the_real_world.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | Git basics are very simple, but it sometimes feels like a bottomless pit when you find yourself on the wrong side of a confusing error situation. It's doubly frustrating because you think that messing up or trying the wrong solution can lose data. It's actually very hard to "lose" data with Git but it can certainly be hiding somewhere you wouldn't think to look without an experienced dev poking around.
4 |
5 | You'll have your share of misadventures, but everyone does. The best remedy is to commit early and often. The smaller and more modular your commits are, the less that can go wrong if you mess one up.
6 |
7 | There's some debate out there about how to properly use Git in your workflow, but I try to think of it this way: Your commit message should fully describe (in present tense) what the commit includes, e.g. "add About section to navbar on static pages". If you need to use a comma or the word "and", you've probably got too much stuff in your commit and should think about keeping your changes more modular and independent.
8 |
9 | It can also be tempting to immediately fix bugs in your code or tweak some CSS as soon as you see it. Everyone's guilty of that (ahem). But it's really best to keep that pen and paper next to you, write down the thing you want to fix, and continue doing what you were doing. Then, when you've committed your current feature or merged its feature branch or somehow extricated yourself from the current problem, go back and tackle the things you wanted to touch originally.
10 |
11 | Again, it's all designed to keep your workflow modular and the commits independent so you can easily jump around your Git timeline without messing up too many other things along the way. The first time you need to go back and modify a single monolithic commit, you'll feel that pain and mend your ways.
12 |
13 | The thing about Git is that, unless you've got a seriously impressive memory, you can't just learn it by reading about it up front... you need to do it. Find a problem you want to go back and fix, hit an error in your merge, etc. and Google the hell out of it, learning a new Git tactic in the process.
14 |
15 | To help you out, come back and refer to this lesson again when you're in trouble. We'll first cover a real-world example of a Github workflow used on this very project. The Additional Resources section below should also help you find high quality resources for when you need them later on.
16 |
17 | ### A Git Workflow For Open Source Contribution
18 |
19 | Let's say you want to contribute to the web application that powers this website(check it out [here](https://github.com/TheOdinProject/theodinproject)). _**NOTE**: this is not the curriculum repo that you have been submitting your project solutions too, this is the main Odin website that pulls the files from the curriculum in._
20 |
21 | How do you do that? This is a production-ready workflow that is actually used by contributors to this website. We'll assume here that you do not have write access to the original repository.
22 |
23 | The key players in this story will be the `upstream` (the original Github repository), the `origin` (your fork of that repo), and the "local" repository (your local clone of `origin`). Think of it as a happy triangle... except that "local" can only pull from `upstream`, not push.
24 |
25 | #### Initial Setup
26 |
27 | 1. Fork the original ("upstream") repository into your own Github account by using the "fork" button at the top of that repo's page on Github.
28 | 2. Clone your forked repository onto your local machine using something like `$ git clone git@github.com:your_user_name_here/theodinproject.git` (you can get the url from the little widget on the sidebar on the right of that repo's page on Github)
29 | 3. Because you cloned the repository, you've already got a remote that points to `origin`, which is your fork on Github. You will use this to push changes back up to Github. You'll also want to be able to pull directly from the original repository on Github, which we'll call `upstream`, by setting it up as another remote. Do this by using `$ git remote add upstream git@github.com:TheOdinProject/theodinproject.git`.
30 | 4. If this is your first time using git, don't forget to set your username and email using:
31 |
32 | ~~~bash
33 | $ git config --global user.name "YOUR NAME"
34 | $ git config --global user.email "YOUR_EMAIL@EXAMPLE.COM"
35 | ~~~
36 |
37 | #### Ongoing Workflow
38 |
39 | We've got two main branches -- `master` and `dev`. `master` is just for production-ready code. Any code deployed to `master` will be tested in staging and shipped to production. You'll be working in a feature branch and submitting your pull requests to the `dev` branch. Pretend `master` doesn't even exist.
40 |
41 | 4. Create a new feature branch for whatever feature you want to build, using `$ git checkout -b your_feature_name`.
42 | 5. Code, commit, code, commit, code, commit (see a pattern?)
43 | 6. When you're done with your feature, odds are that someone has made changes to the upstream repository in the meantime. That means that your `master` and `dev` branches are probably out of date. Fetch the most updated copies of these using `$ git fetch upstream`.
44 | 7. Type `$ git branch --all` to see a list of all the branches, including the ones that are normally hidden (e.g. the remote branches you just grabbed). You should see `upstream/master` and `upstream/dev` among them.
45 | 8. Now merge the upstream's changes into your local version of `dev` using `$ git merge`. Specifically, you'll first want to `$ git checkout dev` to get onto the `dev` branch and then `$ git merge upstream/dev` to merge in those upstream changes that we just fetched.
46 | 9. Note that a `$ git fetch upstream` followed by a `$ git merge upstream/some_branch` is the EXACT same thing as doing a `$ git pull upstream/some_branch`. I prefer to split it up so I can explicitly walk through the steps.
47 | 9. Now that your `dev` branch is up-to-date, you need to merge it into your feature branch. Yes, that is correct and it seems odd at first. Don't you want to merge the feature branch into the `dev` branch instead? Yes, you do, *but not yet*. **Your feature branch is dirty.** You don't know if it has any conflicts which might creep up. Any time you are merging in more "senior" branches (e.g. merging the feature into `dev` or the `dev` into `master`), you want it to be a clean and conflict-free merge. So you first merge the "senior" branch into your dirty branch to resolve those conflicts. So do a `$ git checkout your_feature_name` to jump back onto your feature branch then a `$ git merge dev` to merge `dev` into it.
48 | 9. You may have merge conflicts... resolve those with `$ git mergetool` or just manually open up the files that have conflicts. Basically, merge conflicts will insert markers into your conflicting files to denote what lines are part of the incoming code and which lines are part of your pre-existing code. You'll need to manually edit those files one-by-one (including removing the merge marker text) and then resave them. Once you've finished fixing all the files that have conflicts, you need to commit your changes to finish the merge.
49 |
50 | #### Sending Your Pull Request
51 |
52 | 10. Now that your feature branch is squeaky clean and you know it'll merge cleanly into `dev`, the hard part is all over. Merge into `dev` with `$ git checkout dev` `$ git merge your_feature_name`.
53 | 11. Now you want to send your local version of the `dev` branch back up to your `origin` (your fork of the `upstream` repository). You can't send directly to `upstream` because you don't have access, so you'll need to make a pull request. Use `$ git push origin dev` to ship `dev` up to your fork on Github.
54 | 12. Finally, submit a pull request to send your forked version of `dev` back to the original `upstream` repository's `dev` branch. This can be done using Github's interface. You just need to make sure you're sending it back to the `dev` branch and not the `master` branch.
55 | 13. Shake your moneymaker, you're an OSS contributor!
56 |
57 | ### Learning Outcomes
58 | Look through these now and then use them to test yourself after doing the assignment:
59 |
60 | * How often should you commit?
61 | * How large should your commits be?
62 | * What should your commit messages say?
63 | * Can you commit unfinished features?
64 | * Which workflow should you use? (e.g. Merge? Topic Branches? Git-Flow? Rebase?) Hint: There's no right answer.
65 |
66 | ### Assignment
67 |
68 |
69 | 1. Read [Version Control Best Practices](http://www.git-tower.com/learn/ebook/command-line/appendix/best-practices#start) from Tower.
70 | 2. Skim Seth Robertson's [Git Best Practices](http://sethrobertson.github.io/GitBestPractices/). Don't worry too much about the commands you haven't seen yet... just work on the high level concepts.
71 | 3. Read through this great resource to get a solid understanding of [how git works](http://think-like-a-git.net/)
72 |
73 |
74 | ### Additional Resources
75 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
76 |
77 | * [Git Branching and Tagging Best Practices on SO](http://programmers.stackexchange.com/questions/165725/git-branching-and-tagging-best-practices)
78 | * [Git Best Practices Workflow Guidelines](http://www.lullabot.com/blog/article/git-best-practices-workflow-guidelines)
79 | * Github's [official training site](https://training.github.com/)
80 | * [Understand Git Conceptually](http://www.sbf5.com/~cduan/technical/git/)
81 | * Learn about [Git Branching from Peter Cottle](http://pcottle.github.io/learnGitBranching/) using his interactive branching tutorial.
82 | * Need more still? See [this meta-list of git tutorials for beginners](http://sixrevisions.com/resources/git-tutorials-beginners/).
83 | * [Git Immersion](http://gitimmersion.com/lab_01.html) is another great tutorial to learn the shortcuts of git.
84 |
--------------------------------------------------------------------------------
/ruby_programming/intermediate_ruby/event_attendees.csv:
--------------------------------------------------------------------------------
1 | ,RegDate,first_Name,last_Name,Email_Address,HomePhone,Street,City,State,Zipcode
2 | 1,11/12/08 10:47,Allison,Nguyen,arannon@jumpstartlab.com,6154385000,3155 19th St NW,Washington,DC,20010
3 | 2,11/12/08 13:23,SArah,Hankins,pinalevitsky@jumpstartlab.com,414-520-5000,2022 15th Street NW,Washington,DC,20009
4 | 3,11/12/08 13:30,Sarah,Xx,lqrm4462@jumpstartlab.com,(941)979-2000,4175 3rd Street North,Saint Petersburg,FL,33703
5 | 4,11/25/08 19:21,David,Thomas,gdlia.lepping@jumpstartlab.com,650-799-0000,9 garrison ave,Jersey City,NJ,7306
6 | 5,2/2/09 11:29,Chris,Sackett,fpmorgan07@jumpstartlab.com,613 565-4000,173 Daly Ave,Ottawa,ON,
7 | 6,11/12/08 15:00,Aya,Fuller,jtex@jumpstartlab.com,778.232.7000,2-1325 Barclay Street,Vancouver,BC,90210
8 | 7,11/12/08 16:05,Mary Kate,Curry,wmppydaymaker@jumpstartlab.com,(202) 328 1000,1509 Jackson Street,Baltimore,MD,21230
9 | 8,11/12/08 17:18,Audrey,Hasegan,ffbbieucf@jumpstartlab.com,530-919-3000,1570 Old Ranch Rd.,Placerville,CA,95667
10 | 9,11/13/08 1:32,Shiyu,Armideo,odfarg06@jumpstartlab.com,8084974000,644 Ikemaka PL,Kailua,HI,96734
11 | 10,11/13/08 16:40,Eli,Zielke,jbrabeth.buckley@jumpstartlab.com,858 405 3000,3024 Cranbrook Ct,La Jolla,CA,92037
12 | 11,11/13/08 18:17,Colin,Harmston,qkristie.lencsak@jumpstartlab.com,14018685000,34 blue heron drive,attleboro,MA,2703
13 | 12,11/13/08 21:19,Megan,Doe,wkganize@jumpstartlab.com,315.450.6000,64 King Ave,Columbus,OH,43201
14 | 13,11/16/08 11:44,Meggie,Tippit,dgsanshamel@jumpstartlab.com,510 282 4000,28 Olive Ave.,Piedmont,CA,94611
15 | 14,11/16/08 13:54,Laura,Rapetsky,ikr08@jumpstartlab.com,787-295-0000,Urb Monte Carlo c/15#1287,San Juan,PR,924
16 | 15,11/16/08 20:20,Paul,Fulghum,cnroh@jumpstartlab.com,9.82E+00,shohadaye sadeghiye,Tehran,YK,14517
17 | 16,11/17/08 19:41,Shannon,Warner,gkjordandc@jumpstartlab.com,(603) 305-3000,186 Crooked S Road,Lyndeborough,NH,3082
18 | 17,11/19/08 21:56,Shannon,Davis,ltb3@jumpstartlab.com,530-355-7000,Campion 1108 914 E. Jefferson,Seattle,WA,98122
19 | 18,11/20/08 16:25,Nash,Okaty,qdansonlm@jumpstartlab.com,206-226-3000,914 E Jefferson ST,Seattle,WA,98122
20 | 19,11/23/08 20:44,Amanda,Hartzell,nqm17@jumpstartlab.com,607-280-2000,3515 School St,Valois,NY,14841
21 |
--------------------------------------------------------------------------------
/ruby_programming/intermediate_ruby/lesson_oop.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | You've got the building blocks of Ruby out of the way, great! Now it's time to get into the fun stuff... how do we combine those building blocks in the most efficient and elegant ways to produce the programs we'd like to write?
4 |
5 | The concepts you'll learn here are often less specific to Ruby itself and more widely applicable to any object-oriented language. That's because the fundamental concepts are just that... fundamental. Don't repeat yourself. Modularize your code. Have your classes and methods only do one thing. Show as little of your interfaces to the world as you can. Don't make methods or classes heavily dependent on each other. Be lazy. These will take some time and practice to implement effectively, but you'll already be taking a big step towards creating high quality code just by finishing up this section.
6 |
7 | There's a lot to do here but stick with it! We'll start with the Codecademy lessons, which are interspersed with their projects so you'll get a chance to apply what you're learning. The Beginning Ruby book will help you understand the material a bit deeper, which will be important when you are creating your own projects next.
8 |
9 |
10 | ### Learning Outcomes
11 | Look through these now and then use them to test yourself after doing the assignment:
12 |
13 | #### Classes and Methods:
14 | * What is an implicit return?
15 | * What is a class?
16 | * When should you use a class?
17 | * How do you create a class in your script file?
18 | * What is an instance of a class?
19 | * What is the difference between the CamelCase and snake_case styles of naming?
20 | * How do you instantiate a class?
21 | * How do you set the state of your new instance?
22 | * What should be done in the `#initialize` method?
23 | * What is a class method?
24 | * How is a class method different from an instance method?
25 | * How are methods you already know like `#count` or `#sort` etc instance methods?
26 | * What's the difference between how you declare a class method vs an instance method?
27 | * What's the difference between how you call a class method vs an instance method?
28 | * What is an instance variable?
29 | * What's the difference between an instance variable and a 'regular' variable?
30 | * What are "getter" and "setter" methods used for?
31 | * What is the difference between a "getter" and a "setter" method?
32 | * How do you make instance variables readable outside your class? Writeable? Both at the same time?
33 | * Can a class call its own class methods?
34 | * What's the difference between when you would use a class variable and when you would use a constant?
35 | * What's the difference between a class and a module?
36 | * When would you use a class but not a module?
37 | * How does inheritance work?
38 | * Why is inheritance really useful?
39 | * How do you extend a class? What does that mean?
40 | * What does `#super` do? Why use it?
41 |
42 | #### Scope:
43 | * What is scope?
44 | * When can you start using a variable?
45 | * When is a new scope defined?
46 | * When are methods in scope?
47 | * What is a private method?
48 | * What is a protected method?
49 | * How are private and protected methods different?
50 | * What does "encapsulation" mean?
51 |
52 | ### Assignment
53 |
54 |
55 | 1. Do [Codecademy Ruby sections 9 and 10](https://www.codecademy.com/learn/learn-ruby):
56 | 1. Object-Oriented Programming, Part I
57 | 2. Project: Virtual Computer
58 | 3. Object-Oriented Programming, Part II
59 | 4. Project: Banking on Ruby
60 | 2. Take a brief break from code and learn more about the world of Ruby:
61 | 1. Read about the [History of Ruby](https://www.sitepoint.com/history-ruby/)
62 | 2. Read about [Open Source Culture](https://opensource.guide/how-to-contribute/#why-contribute-to-open-source) in Section 1
63 | 3. Read about where you can find [Ruby's Community](https://www.ruby-lang.org/en/community/)
64 | 3. Read [Beginning Ruby](https://books.google.com.pk/books?id=MiGpDAAAQBAJ&printsec=frontcover#v=onepage&q&f=false) Chapter 6: `Classes, Objects, and Modules`. It will extend your knowledge deeper than Codecademy alone.
65 | 4. Read [Beginning Ruby](https://books.google.com.pk/books?id=MiGpDAAAQBAJ&printsec=frontcover#v=onepage&q&f=false) Chapter 7: `Projects and Libraries`
66 | 5. Read [Beginning Ruby](https://books.google.com.pk/books?id=MiGpDAAAQBAJ&printsec=frontcover#v=onepage&q&f=false) Chapter 8: `Documentation and Error Handling` but skip the stuff on Testing (pgs 175-179)
67 | 6. Read through these reinforcing posts by Erik Trautman to help you answer the questions in the "Learning Outcomes" section:
68 | 1. [Ruby Explained: Classes](http://www.eriktrautman.com/posts/ruby-explained-classes)
69 | 2. [Ruby Explained: Inheritance and Scope](http://www.eriktrautman.com/posts/ruby-explained-inheritance-and-scope)
70 | 7. Read the [Bastard's Chapter on Error Handling](http://ruby.bastardsbook.com/chapters/exception-handling/) to reinforce your understanding of dealing with errors.
71 | 8. Glance over the [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide) so you have an idea of how to make your code look more professional.
72 |
73 |
74 | ### Test Yourself
75 |
76 |
77 | 1. Make sure you can do [Quiz #5](http://www.codequizzes.com/ruby/beginner/intro-object-oriented-programming) from [Code Quizzes](http://www.codequizzes.com).
78 | 2. Make sure you can do [Quiz #7](http://www.codequizzes.com/ruby/beginner/modules-classes-inheritance) as well.
79 | 3. Make sure you go back up and look at all the questions from the "Learning Outcomes" section. See if you can do most of them without looking back through the text.
80 |
81 |
82 | ### Additional Resources
83 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
84 |
85 | * If you'd still like to learn more about how to really design more concise, effective, purposeful classes, check out [Practical Object-Oriented Design in Ruby](https://amzn.com/B0096BYG7C) by Sandi Metz.
86 | * [This video presentation from Kevin Berridge](http://vimeo.com/91672848) covers major themes of practical object-oriented design, with many references to Sandi Metz's book, in about 40 minutes.
87 | * [Zetcode's Variables section](http://zetcode.com/lang/rubytutorial/variables/).
88 | * Now you're ready to read through [Zetcode's OOP section](http://zetcode.com/lang/rubytutorial/oop/).
89 | * For an alternative read to Beginning Ruby's chapters on OOP, check out [Launch School's OOP](https://launchschool.com/books/oo_ruby/read/introduction).
90 | * Read through [Zetcode's second OOP section](http://zetcode.com/lang/rubytutorial/oop2/) until they start talking about exceptions (~80% of the way down).
91 |
92 |
--------------------------------------------------------------------------------
/ruby_programming/intermediate_ruby/lesson_serialization.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | Until now you've mostly been working with self-contained command line programs. It's time to start branching out and interacting with files. Files are basically just collections of bits and bytes that you'll somehow need to open, read into your program, modify, and save. Even though many files (like images) look like a giant jumble of data when you open them up in a text editor, it can be helpful to think of all files as one really long string, or stream, of bytes. Your script will read them in from top to bottom, performing whatever operations you specify along the way.
4 |
5 | Lucky for you, Ruby makes your life pretty easy with regards to dealing with files. It has the tools necessary to read those long streams of bytes into your program and then allow you to work with them using the objects you're familiar with. As long as you remember that the files are just a long stream of words/characters/bytes being read in from top to bottom, it should be fairly intuitive. If you want to do more detailed stuff like write to a specific point in a file, you'll need to figure out what position you're at first, since you may be in the middle of it somewhere.
6 |
7 | Working with files gets you into the idea of serialization, which basically just means converting your data into a storable format like a string. That's very useful whether you're thinking of saving your objects and classes (say, when you're in the middle of a game) to a file or when you're transmitting those same types of objects to the web browser (since the only way for information to travel via HTTP is as a string).
8 |
9 | Luckily, Ruby again makes things pretty easy for you. There are some generally accepted formats for serializing data and Ruby gives you the tools you'll need to work with all of them. The two you'll run into again and again are YAML and JSON. You often see YAML used to save configuration files in Ruby on Rails because it's very lightweight and straightforward. You can read it easily in a text editor. JSON is ubiquitous across the web, and is the format of choice to deliver complex or deeply nested data (like objects) from some website to your program via an API (like if you want to interface with Google Maps).
10 |
11 | Finally, files and serialization overlaps in a lot of ways with the idea and purpose of databases -- they facilitate the ability to maintain state and permanence for your data. We'll briefly look into some basic database connections that Ruby provides as well.
12 |
13 | ### Learning Outcomes
14 | Look through these now and then use them to test yourself after doing the assignment.
15 |
16 | * What are two ways to store a file from your hard drive into a string or array in your Ruby script?
17 | * What are three things made possible or much easier by serialization?
18 | * What is JSON?
19 | * What is YAML?
20 | * How do you turn a Ruby object into JSON?
21 | * How do you turn JSON into a Ruby object?
22 |
23 | ### Assignment
24 |
25 |
26 | 1. Read [Thoughtbot's I/O in Ruby](https://robots.thoughtbot.com/io-in-ruby). You can ignore both the 'Putting it all together' and the 'Working with disparate APIs' sections.
27 | 2. Watch [icc0612's introduction to serialization](https://www.youtube.com/watch?v=uS37TujnLRw). It will explain the concept of serialization before you implement it in Ruby.
28 | 3. Read [Alan Skorkin's](http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/) post about serialization. It's from 2010 so some of the code is outdated, but it's a good introduction to the subject.
29 | 4. Read [Choosing the Right Serialization Format](https://www.sitepoint.com/choosing-right-serialization-format/) for more information about the various serialization options you can choose from.
30 | 5. Read [Beginning Ruby](https://www.amazon.co.uk/Beginning-Ruby-Professional-Peter-Cooper/dp/1484212797) Chapter 4: `Developing Your First Ruby Application` and follow along with the tutorial.
31 | 6. Read [Beginning Ruby](https://www.amazon.co.uk/Beginning-Ruby-Professional-Peter-Cooper/dp/1484212797) Chapter 9: `Files and Databases`. Much of the databases stuff will be review from the Web Development 101 course and at first you won't often use the connection methods yourself (often an ORM like ActiveRecord for Rails will have that code already written for you), so feel free to skim over it but do try to see what Ruby is capable of.
32 | 7. Read the [Chapter on File I/O](http://ruby.bastardsbook.com/chapters/io/) of the Bastard's Book of Ruby. Much of it will go quickly for you given what you've already read, but there are some new nuggets in there.
33 |
34 |
35 | ### Additional Resources
36 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
37 |
38 | * [Zetcode's section on Input/Output in Ruby](http://zetcode.com/lang/rubytutorial/io/) should be another useful perspective on the material.
39 | * [Ruby Monk's section on Serializing](https://web.archive.org/web/20160505174806/http://rubymonk.com/learning/books/4-ruby-primer-ascent/chapters/45-more-classes/lessons/104-serializing)
40 |
--------------------------------------------------------------------------------
/ruby_programming/intermediate_ruby/project_file_io.md:
--------------------------------------------------------------------------------
1 | ### Project: Hangman
2 |
3 | Files are a great way to save and reload a game, so we'll give it a shot here by building [Hangman](https://en.wikipedia.org/wiki/Hangman_(game)).
4 |
5 | ### Assignment
6 | You will be building a simple command line Hangman game where one player plays against the computer, but a bit more advanced. If you're unfamiliar with how Hangman works, see Wikipedia.
7 |
8 |
9 | 1. Download the `5desk.txt` dictionary file from [http://scrapmaker.com/](http://scrapmaker.com/view/twelve-dicts/5desk.txt).
10 | 2. When a new game is started, your script should load in the dictionary and randomly select a word between 5 and 12 characters long for the secret word.
11 | 3. You don't need to draw an actual stick figure (though you can if you want to!), but do display some sort of count so the player knows how many more incorrect guesses he/she has before the game ends. You should also display which correct letters have already been chosen (and their position in the word, e.g. `_ r o g r a _ _ i n g`) and which incorrect letters have already been chosen.
12 | 2. Every turn, allow the player to make a guess of a letter. It should be case insensitive. Update the display to reflect whether the letter was correct or incorrect. If out of guesses, the player should lose.
13 | 3. Now implement the functionality where, at the start of any turn, instead of making a guess the player should also have the option to save the game. Remember what you learned about serializing objects... you can serialize your game class too!
14 | 4. When the program first loads, add in an option that allows you to open one of your saved games, which should jump you exactly back to where you were when you saved. Play on!
15 |
16 |
17 | ### Student Solutions
18 | Send us your solution so we can show others! Submit a link to the Github repo with your files in it here using any of the methods listed on the [contributing page](http://github.com/TheOdinProject/curriculum/blob/master/contributing.md). Please include your partner's github handle somewhere in the description if they would like attribution.
19 |
20 | * Add your solution below this line!
21 | * [Dreniak's Solution](https://github.com/Dreniak/hangman) - [Repl.it Live Version](https://repl.it/@Dreniak/TerminalHANGMAN)
22 | * [Mohamed Elattar's Solution](https://github.com/mohamed-elattar/hangman) - [Repl.it Live Version](https://repl.it/@mohamed_attar/hangman)
23 | * [prw001's Solution](https://github.com/prw001/hanged_man)
24 | * [brndntng's solution](https://github.com/brndntng/hangman)
25 | * [Max Garber's Solution](https://github.com/bubblebooy/miscellaneous-exercises/tree/master/hangman)
26 | * [Malaika(Mic) Solution](https://github.com/malaikaMI/Hangman_Game)
27 | * [Reece Pritchard's Solution](https://github.com/rapritchard/ruby-hangman)
28 | * [Leight Johnson's Solution](https://github.com/leightjohnson93/Hangman)
29 | * [Nathan Sherburne's Solution](https://github.com/nathansherburne/ruby_practice/tree/master/hangman)
30 | * [Sherman Bowling's Solution](https://github.com/janus0/top_course_work/tree/master/ruby/project_hangman)
31 | * [Lucas Manzano's Solution](https://github.com/lucasmfarias1/hangman)
32 | * [Javier Machin's Solution](https://github.com/Javier-Machin/Hangman)
33 | * [Isil Donmez's Solution](https://github.com/isildonmez/files_and_serialization_projects/tree/master/hangman)
34 | * [Samuel Masters' Solution](https://github.com/redeyetuning/rb_hangman)
35 | * [Btreim's solution](https://github.com/btreim/ruby/tree/master/hangman)
36 | * [Demo318's solution](https://github.com/Demo318/ruby_hangman)
37 | * [Jackie Fahmy's solution](https://github.com/jfahmy/Ruby/tree/master/ProjectOdin/hangman)
38 | * [OthmanAmoudi's solution](https://github.com/OthmanAmoudi/hangman) - [View in Browser](https://repl.it/@theweeknd/hangman)
39 | * [Omar Moataz's solution](https://github.com/omarmoatazpracticehub/Hangman)
40 | * [Ben Deltenre's solution](https://github.com/benjdelt/hangman)
41 | * [Andrew's solution](https://github.com/andrewr224/Hangman)
42 | * [Jason McKee's solution](https://github.com/jttmckee/odin-project-ruby/tree/master/hangman)
43 | * [Jonathan Yiv's solution](https://github.com/JonathanYiv/hangman)
44 | * [Bn8's solution](https://github.com/Bn8/ruby_odin/tree/master/Hangman)
45 | * [Dallaire's solution](https://github.com/Dallaire/hangman.git)
46 | * [justinckim3's solutions](https://github.com/justinckim3/hangman)
47 | * [Kasey Z.'s solution](https://github.com/kasey-z/TOP-solutions/tree/master/file_io_and_serialization/hangman)
48 | * [SadieD's solution](https://github.com/SadieD/FileIO/tree/master/hangman)
49 | * [Clayton Sweeten's Solution](https://github.com/cjsweeten101/OdinProjects/tree/master/serialization_and_files/hangman)
50 | * [holdercp's solution](https://github.com/holdercp/hangman)
51 | * [jfonz412's solution](https://github.com/jfonz412/hangman/blob/master/lib/game.rb)
52 | * [xavier solution](https://github.com/nxdf2015/odin-serialization/tree/master/Hangman)
53 | * [Webdev-burd's solution](https://github.com/webdev-burd/hangman)
54 | * [thisisned's solution](https://github.com/thisisned/hangman)
55 | * [Ovsjah Schweinefresser's Solution](https://github.com/Ovsjah/serialization/tree/master/hangman)
56 | * [Oleh Sliusar's solution](https://github.com/OlehSliusar/hangman)
57 | * [Nikolay Dyulgerov's solution](https://github.com/NicolayD/ruby-serialization/tree/master/hangman)
58 | * [mindovermiles262's Solution](https://github.com/mindovermiles262/hangman)
59 | * [theghall's solution](https://github.com/theghall/hangman.git)
60 | * [Josh Campanella's solution](https://github.com/joshcamp503/hangman)
61 | * [Jerliyah's solution](https://github.com/Jerliyah/hangman)
62 | * [yilmazgunalp's solution](https://github.com/yilmazgunalp/hangman)
63 | * [Austin Norman's solution (with hd ascii graphics)](https://github.com/austinnormancore/hangman)
64 | * [ToTenMilan's solution](https://github.com/ToTenMilan/the_odin_project/tree/master/ruby/serialization/hangman)
65 | * [Ayushka's solution](https://github.com/ayushkamadji/hangman_ruby)
66 | * [Nicolas Amaya's solution](https://github.com/nicoasp/TOP---Ruby-IO-project)
67 | * [John Phelps's Solution](https://github.com/jphelps413/odin-ruby/tree/master/hangman)
68 | * [Raiko's Solution](https://github.com/Cypher0/hangman)
69 | * [Charles's Solution](https://github.com/codexTun/ODIN-PROJECTS/tree/master/Ruby_projects/hangman)
70 | * [Jib's Solution](https://github.com/NuclearMachine/OdinTasks/tree/master/Hang_man)
71 | * [Afshinator's solution](https://github.com/afshinator/playground/tree/master/Hangman) - [View in browser](http://htmlpreview.github.io/?https://github.com/afshinator/playground/blob/master/Hangman/index.html)
72 | * [Jamie's solution](https://github.com/Jberczel/odin-projects/tree/master/hangman)
73 | * [Chris's solution](https://github.com/krzoldakowski/theodinproject/tree/master/hangman_fileio)
74 | * [Jayrobin's solution](https://github.com/jayrobin/hangman)
75 | * [Donald's solution](https://github.com/donaldali/odin-ruby/tree/master/project_serialization/hangman)
76 | * [Alan Russell's solution](https://github.com/ajrussellaudio/hangman)
77 | * [Marina Sergeyeva's solution](https://github.com/imousterian/OdinProject/tree/master/Project2_4_Ruby_FileIO/hangman)
78 | * [TomTom's solution](https://github.com/tim5046/projectOdin/blob/master/FilesAndSerialization/Hangman/)
79 | * [Tommy Noe's solution](https://github.com/thomasjnoe/hangman)
80 | * [Michael Alexander's solution](https://github.com/betweenparentheses/hangman)
81 | * [Sahil Agarwal's solution](https://github.com/sahilda/the_odin_project/tree/master/file-io-serialization/hangman)
82 | * [Adrian Badarau's solution](https://github.com/adrianbadarau/Hang-Man-Game)
83 | * [James MacIvor's solution](https://github.com/RobotOptimist/hangman)
84 | * [Hawkeye's solution](https://github.com/Hawkeye000/hangman)
85 | * [Aleksandar's solution](https://github.com/rodic/Odin-Ruby-Projects/tree/master/Project:%20Serialization%20and%20Working%20with%20Files/hangman)
86 | * [Vidul's solution](https://github.com/viparthasarathy/hangman)
87 | * [John Quarles' solution](https://github.com/johnwquarles/Ruby-FileIO-Hangman)
88 | * [Artur Janik's solution](https://github.com/ArturJanik/TOPRuby/tree/master/Project4/Hangman)
89 | * [Kate McFaul's solution](https://github.com/craftykate/odin-project/tree/master/Chapter_03-Advanced_Ruby/serialization_and_files/hangman)
90 | * [Dominik Stodolny's solution](https://github.com/dstodolny/hangman)
91 | * [Lara Finnegan's solution](https://github.com/lcf0285/hangman)
92 | * [Nikola Čvorović's solution](https://github.com/cvorak/Hangman.git)
93 | * [Dawn Pattison's solution](https://github.com/pattisdr/theOdinProject/tree/master/hangman)
94 | * [Kevin Mulhern's solution](https://github.com/KevinMulhern/serialization/tree/master/hangman)
95 | * [Rafael E's solution](https://github.com/NerdDiffer/hangman)
96 | * [LongPotato's solution](https://github.com/LongPotato/Hangman_GUI)
97 | * [Eduardo Frias' solution](https://github.com/feek1g/theodinproject/tree/master/Hangman)
98 | * [Jeremy Mauzy's solution](https://github.com/apositivejam/the_odin_project/tree/master/hangman)
99 | * [Frank Peelen's solution](https://github.com/FrankPeelen/Hangman/blob/master/hangman.rb)
100 | * [Brann James' solution](https://github.com/brannj/The_Odin_Project/blob/master/serialization/hangman/lib/hangman.rb)
101 | * [Chris Hall's solution](https://github.com/Concretechris/odinProject/tree/master/OP%20-%20hangman)
102 | * [Greg Park's solution](https://github.com/gregoryjpark/Hangman)
103 | * [ll14m4n's solution](https://github.com/ll14m4n/the-odin-project/tree/master/3_Ruby_hangman)
104 | * [AtActionPark's solution](https://github.com/AtActionPark/odin_hangman)
105 | * [Matias Pan's solution](https://github.com/kriox26/odin_ruby/tree/master/project_serializing/hangman)
106 | * [Jon Yorg's solution](https://github.com/Yorgg/Ruby-Stuff/tree/master/hangman)
107 | * [Mark Viola's solution](https://github.com/markviola/the-odin-project/tree/master/9-serialization-and-files/2%20-%20Hangman)
108 | * [Alex Chen's solution](https://github.com/Chenzilla/hangman_with_save)
109 | * [Joe Balsamo's solution](https://github.com/Joe-Balsamo/hangman)
110 | * [Cody Gipson's solution](https://github.com/Cgipson06/Hangman)
111 | * [Dan Hoying's solution](https://github.com/danhoying/file_io_and_serialization/tree/master/hangman)
112 | * [hiendinhngoc's solution](https://github.com/hiendinhngoc/TheOdinProject/tree/master/ruby/hangman)
113 | * [Raycotek's solution](https://github.com/Raycotek/Odinprojects/blob/master/hangman/hangman.rb)
114 | * [John Tobillo's solution](https://github.com/jdtobill/Ruby/tree/master/games/hangman)
115 | * [PiotrAleksander's solution](https://github.com/PiotrAleksander/Ruby/blob/master/Szubienica.rb)
116 | * [Noah Prescott's solution](https://github.com/npresco/top/tree/master/serialization/hangman)
117 | * [Florian Mainguy's solution](https://github.com/florianmainguy/theodinproject/tree/master/ruby/serialization-and-working-with-files/hangman)
118 | * [lynchd2's solution](https://github.com/lynchd2/TOP-Ruby-Programming/tree/master/hangman)
119 | * [Aviv Levinsky's solution](https://github.com/pugsiman/Hang_Man/blob/master/hangman.rb)
120 | * [Alex Tsiras' solution](https://github.com/arialblack14/hangman)
121 | * [Scott Bobbitt's solution](https://github.com/sco-bo/hangman)
122 | * [Sander Schepens's solution](https://github.com/schepens83/theodinproject.com/blob/master/ruby/project8--hangman/hangman.rb)
123 | * [Giorgos Mitsis's solution](https://github.com/vinPopulaire/hangman)
124 | * [Andrew Park's solution](https://github.com/akpark93/the_odin_project/tree/master/ruby_programming_projects/hangman)
125 | * [poctek's solution](https://github.com/poctek/The_Odin_Project_Files/blob/master/Projects/Hangman/hangman.rb)
126 | * [srashidi's solution](https://github.com/srashidi/Files_and_Serialization/tree/master/hangman)
127 | * [James Brooks's solution](https://github.com/jhbrooks/hangman)
128 | * [cdouglass's solution](https://github.com/cdouglass/odin-project-exercises/tree/master/ruby/file-i-o/hangman)
129 | * [Skye Free's solution](https://github.com/swfree/the-odin-project/tree/master/hangman)
130 | * [djhart's solution](https://github.com/djhart/hangman)
131 | * [Eric's solution](https://github.com/em77/hangman)
132 | * [Ricardo Villegas' solution](https://github.com/claricardo/RubyBuildingBlocks/blob/master/hangman.rb)
133 | * [Luke Walker's solution](https://github.com/ubershibs/ruby-programming/tree/master/hangman)
134 | * [Miguel Herrera's solution](https://github.com/migueloherrera/projects/blob/master/hangman.rb)
135 | * [Tomasz Kula's solution](https://github.com/zetsnotdead/hangman)
136 | * [Max Gallant's solution](https://github.com/mcgalcode/Ruby/tree/master/IOProjects)
137 | * [noobling's soltion](https://github.com/noobling/ruby/tree/master/hang_man)
138 | * [Barltomiej Lazarski's solution](https://github.com/YogAzathoth/hangman)
139 | * [Diarmuid Murphy's solution](https://github.com/diarmuid-murphy/hangman)
140 | * [John's Solution](https://github.com/johnTheDudeMan/the_odin_project/blob/master/hangman/hangman.rb)
141 | * [Fabricio Carrara's solution (with sweet ASCII)](https://github.com/fcarrara/hangman)
142 | * [DV's solution](https://github.com/dvislearning/hangman/blob/master/hangman.rb)
143 | * [Deepak' solution](https://github.com/Deepak5050/hangman/blob/master/hangman.rb)
144 | * [Shala Qweghen's solution](https://github.com/ShalaQweghen/serialization/tree/master/hangman)
145 | * [Earth35's solution](https://github.com/Earth35/hangman)
146 | * [Austin Mason's solution](https://github.com/CouchofTomato/hangman)
147 | * [Cyprium (Stefan)'s solution](https://github.com/dev-cyprium/Hangman-Ruby)
148 | * [Alejandro Corredor's solution](https://github.com/aecorredor/hangman)
149 | * [Lani Huang's solution](https://github.com/laniywh/the-odin-project/tree/master/ruby-programming/serialization-project/hangman)
150 | * [John Connor's solution](https://github.com/jacgitcz/hangman)
151 | * [Francisco Carlos's solution](https://github.com/fcarlosdev/the_odin_project/tree/master/file_io_serialization/hangman)
152 | * [Jean Merlet's solution](https://github.com/jeanmerlet/ruby_games/tree/master/hangman)
153 | * [Sasho's solution](https://github.com/sashoa/the-odin-project/tree/master/project-serialization/hangman)
154 | * [Amrr Bakry's solution](https://github.com/Amrrbakry/learning_ruby/tree/master/hangman)
155 | * [Oscar Y.'s solution](https://github.com/mysteryihs/ruby_projects/tree/master/hangman)
156 | * [Peuchen's solution](https://github.com/Peuchen/hangman)
157 | * [Jiazhi Guo's solution](https://github.com/jerrykuo7727/Hangman)
158 | * [J-kaizen's solution](https://github.com/J-kaizen/TheOdinProject/tree/master/Ruby/hangman)
159 | * [cs-rail's solution](https://github.com/csrail/hangman)
160 | * [Loris Aranda's solution](https://github.com/LorisProg/ruby_hangman-game)
161 | * [Anthony Vumbaca's solution](https://github.com/tvumbaca/hangman)
162 | * [Clint's solution](https://github.com/tholymap/Odin-Ruby-Files)
163 | * [Ryan Armstrong's solution](https://github.com/ryan-kwan-do/ruby_projects/tree/master/files_and_serialization/hangman)
164 | * [Derek K's solution](https://github.com/dckwong/ProjectSerialization/tree/master/hangman)
165 | * [m-chrzan's solution](https://github.com/m-chrzan/hangman)
166 | * [Dom Goj's solution](https://github.com/booyakuhhsha/eventManagerHangman/tree/master/hangman)
167 | * [David Chapman's solution](https://github.com/davidchappy/odin_training_projects/tree/master/hangman)
168 | * [Hassan's solution](https://github.com/HassanTC/Ruby_TheOdinProject/tree/master/The%20odin%20project%20(Ruby%20projects)/Intermediate-Ruby/Hangman)
169 | * [Jerry Gao's solution](https://github.com/blackwright/odin/tree/master/ruby_hangman)
170 | * [Dominik Chomicki's solution](https://github.com/hamstersky/the_odin_project/tree/master/hangman)
171 | * [Jakub Peikert's solution](https://github.com/JPeikert/odin_project/tree/master/ruby/serialization/hangman)
172 | * [Sophia Wu's solution](https://github.com/SophiaLWu/project-file-IO-and-serialization-with-ruby/tree/master/hangman)
173 | * [Samuel Langenfeld's solution](https://github.com/SamuelLangenfeld/hangman)
174 | * [Kyle Thomson's solution](https://github.com/idynkydnk/hangman)
175 | * [Braydon Pacheco's solution](https://github.com/pacheeko/hangman/blob/master/lib/hangman.rb)
176 | * [Bishal's Solution](https://github.com/biiishal/hangman)
177 | * [Cody Buffaloe's Solution](https://github.com/CodyLBuffaloe/hangman)
178 | * [nmac's solution](https://github.com/nmacawile/Hangman)
179 | * [Robert Szabo's solution](https://github.com/Siker001/the_odin_project_exercises/tree/master/ruby/serialization/hangman)
180 | * [smilesr's solution](https://github.com/smilesr/op-rb-ir-25-hangman)
181 | * [HenrytheDJ's Wild West solution](https://github.com/henrythedj/hangman)
182 | * [Zach Beaird's solution](https://github.com/zbbeaird89/Hangman)
183 | * [jeff1st's solution](https://github.com/jeff1st/hangman)
184 | * [Luján Fernaud's solution](https://github.com/lujanfernaud/ruby-hangman)
185 | * [EMuchynski's solution](https://github.com/EMuchynski/hangman)
186 | * [Pat's solution](https://github.com/Pat878/Hangman)
187 | * [Neil Cudden's solution](https://github.com/ncud4bloc/hangman/)
188 | * [Roland Studer's solution](https://github.com/RolandStuder/odin_project_solutions/tree/master/file-i-o-and-serialization/hangman)
189 | * [Barjits solution](https://github.com/barjit/hangman)
190 | * [Riley's solution](https://github.com/keymaster777/Hangman)
191 | * [Anistor86's solution](https://github.com/anistor86/hangman)
192 | * [Kusnierewicz solution](https://github.com/Kusnierewicz/Hangman-game)
193 | * [Alex's solution](https://github.com/alexcorremans/guess_the_word)
194 | * [Alexander Luna's solution](https://github.com/Mycroft1891/my-odin-project/tree/master/ruby_programming/hangman)
195 | * [HSaad's solution](https://github.com/HSaad/hangman)
196 | * [Punnadittr's solution](https://github.com/punnadittr/hangman)
197 | * [Agon Idrizi's solution](https://github.com/AgonIdrizi/Hangman)
198 | * [Akash's solution](https://github.com/Akash-sopho/hangman)
199 | * [mojotron's solution](https://github.com/mojotron/hangman)
200 | * [dmarkiewicz's solution](https://github.com/dmarkiewicz/the-odin-project/tree/master/Ruby/hangman-project)
201 | * [Felipe Parreira's solution](https://github.com/FelipeParreira/TheOdinProject/tree/master/ruby-programming/intermediate-ruby/File_IO_%26_Serialization/hangman)
202 |
--------------------------------------------------------------------------------
/ruby_programming/testing_with_rspec/lesson_intro_to_rspec.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | By now you've had some experience writing actual programs using Ruby. Presumably, you've been making sure they work by manually entering certain things in the command line over and over again. This was probably especially frustrating with some of the more complex projects you just did during the Algorithms and Data Structures lesson.
4 |
5 | As you should recall from the Web Development 101 course, testing with RSpec lets you automate most of these activities. It also allows you to make sure your programs' interfaces with the public are functioning properly. It allows you to have confidence in your code and to not worry about changing things that may break stuff because you'll know immediately what broke and can more easily determine why. If you end up contributing to an open-source project, they'll want you to include specs to test whatever features you've created.
6 |
7 | At the most basic level, RSpec is a "Domain Specific Language" (DSL, meaning it just does a very specific thing) written in Ruby that is designed to help you test your Ruby code. You use it by including the `rspec` gem, which is really just a package containing 3 other gems -- `rspec-core`, `rspec-expectations` and `rspec-mocks`. It's configured so that, once you've got the gem included, if you've laid out your project folders in the right places, you can just execute the specs directly from the command line. If you did the Test-First project in the Web Development 101 course, you should already be quite familiar with it.
8 |
9 | We will cover testing in more depth in the Rails course, but you'll want to get a good base built in testing "plain old" Ruby first. It will also help you with the final project since you might otherwise find yourself endlessly entering data into the command line and using the debugger.
10 |
11 | It's difficult to find good resources to teach RSpec for free. There are some decent paid resources (listed in the "Additional Resources" section below) but the free ones are very dispersed. The way you'll likely learn it is by knowing you want to do something and then Googling around for how to test it, or going through a tutorial where someone is using it.
12 |
13 | ### Learning Outcomes
14 | Look through these now and then use them to test yourself after doing the assignment:
15 |
16 | * How do you run an RSpec test suite?
17 | * How do you write a basic RSpec test?
18 | * What aspects of your methods should you test?
19 | * What is a stub?
20 | * What is a mock?
21 | * What is a double?
22 | * How are they different?
23 | * When would you use them?
24 |
25 | ### Assignment
26 |
27 |
28 | 1. Go back to the Web Development 101 course and do the [RSpec section](/courses/web-development-101/lessons/ruby) if you haven't already.
29 | 2. Get started writing your own tests by reading [this 3-part series](https://semaphoreci.com/community/series/learn-rspec) and following the tutorial in part 1.
30 | 3. Take a glance at the [Relish RSpec official documentation](https://www.relishapp.com/rspec/rspec-core/v/3-5/docs/). It will be a good resource for when you're scratching your head later.
31 | 4. Glance through [Better Specs](http://www.betterspecs.org/), which shows tons of examples of what you should and shouldn't do with RSpec.
32 |
33 |
34 | ### Additional Resources
35 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
36 |
37 | * [This Tutorials Point guide](https://www.tutorialspoint.com/rspec/index.htm) is another beginners tutorial but covers a wider range of rspec features.
38 | * [The RSpec Book](http://www.amazon.com/The-RSpec-Book-Behaviour-Development/dp/1934356379) is THE book on RSpec, but at this point it's a little out-dated.
39 | * [RSpec::Core Cheat Sheet](http://www.rubypigeon.com/posts/rspec-core-cheat-sheet/) and [RSpec::Expectations Cheat Sheet](http://www.rubypigeon.com/posts/rspec-expectations-cheat-sheet/) explain the basics in a simple way.
40 | * The [RSpec Cheat Sheet](http://www.anchor.com.au/wp-content/uploads/rspec_cheatsheet_attributed.pdf) should help you avoid Googling every new bit of syntax.
41 | * Read the [Wikipedia Page on Test Driven Development](http://en.wikipedia.org/wiki/Test-driven_development) for context on TDD if you're still feeling unfamiliar.
42 | * Check out [This Blog Post](https://8thlight.com/blog/uncle-bob/2013/05/27/TheTransformationPriorityPremise.html) for some more insight on OOP
43 |
--------------------------------------------------------------------------------
/web_development_101/the_backend/database_basics_lesson.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | We've talked about the client-side and the server-side but how do we keep ahold of all our user's data? Who remembers that your login password is `CatLover1985` so you can sign into the website? The bottom layer of any web application is the database and it handles all the remembering for you (we'll cover caching much later). It can be relatively simple, like an excel spreadsheet, or incredibly complex and split into many giant pieces like Facebook's.
4 |
5 | Databases are kind of hidden in the back of the web application so people treat them with a sort of suspicion and awe. **That's nonsense and you should get over it** -- your database and you are going to become very good friends (or at least frenemies). By the end of this curriculum, you're going to understand what's going on with your databases and be able to interact with them like a pro (and probably better than some people you'll work with). This lesson is a teaser for that.
6 |
7 | Compared to a normal programming language like you've already learned, SQL (Structured Query Language), which is used to query databases, is a very simple syntax... there are only a small handful of verbs to learn. What trips people up is that you need to be able to visualize in your head what it's going to be doing. We'll spend a fair bit of time on SQL and databases because they're so fundamental, but for now we'll just cover enough to get you familiar with what's going on in there.
8 |
9 | ### Learning Outcomes
10 | Look through these now and then use them to test yourself after doing the assignment
11 |
12 | * What is a database?
13 | * What are relational databases?
14 | * How are relational databases different from XML?
15 | * What is SQL?
16 | * What is SQL used for?
17 | * What does CRUD stand for?
18 | * Why is the idea of "CRUD" so important for web apps?
19 | * How do you get all the records from a table in SQL?
20 | * How do you insert a record in SQL?
21 | * What is a primary key?
22 | * What is a foreign key?
23 |
24 | ### Assignment
25 |
26 |
27 |
28 | 1. Check out this [introduction](https://launchschool.com/books/sql/read/introduction) of how SQL can be used to organize and manage an overwhelming amount of data. (You do not need to go any further than the first page in the introductions.)
29 | 2. Watch this [short video introduction to relational databases](http://www.youtube.com/watch?v=z2kbsG8zsLM) to get a feel for why this stuff is useful and some more exposure to the terminology we'll use.
30 | 3. Go through this [Khan Academy tutorial](https://www.khanacademy.org/computing/hour-of-code/hour-of-sql/v/welcome-to-sql), to get a feel for actually creating and manipulating databases
31 |
32 |
33 |
34 | ### Additional Resources
35 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
36 |
37 | * [What is a Relational Database?](http://computer.howstuffworks.com/question599.htm) from HowStuffWorks.com
38 | * A brief [Simple Wiki article describing relational databases](http://simple.wikipedia.org/wiki/Relational_database)
39 | * Hunter Ducharme created [an e-book](http://hgducharme.gitbooks.io/sql-basics/) which is a great documentation on how to do all the basics in SQL.
40 | * For more repetitions with the material, check out [SQL Teaching](http://www.sqlteaching.com), the "Codecademy for SQL" (and let us know what you think).
41 |
--------------------------------------------------------------------------------
/web_development_101/the_backend/introduction_to_the_backend_lesson.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | The three languages of the front end are fairly standardized -- HTML for Markup, CSS for Presentation, and Javascript for Scripting. The back end is a different story... you can run pretty much anything you want to on your server since it doesn't rely on your user's browser understanding what's going on. All the browser cares about is whether you've sent it properly formatted HTML, CSS and Javascript files (and other assets like images). That's led to a whole lot of different choices for back-end languages. As long as it can take in an HTTP request and spit out some HTML, you can probably put it on a server somehow.
4 |
5 | That said, some languages are more popular and practical than others. If you're running your own server, you have a ton of flexibility but plenty of headaches. If you're deploying to the cloud (which we will be doing later), you may be restricted to those languages which your cloud provider has installed on their platform... it doesn't do you much good if the servers you're "borrowing" from can't understand your code!
6 |
7 | Some of the most popular server-side languages are PHP, ASP.NET, Ruby, Python and Java (not to be confused with Javascript). And just like I can say "which way to the nearest pub?" in Swedish, French, Italian, English and Bad English, all of those languages can perform almost exactly the same functions, just using different syntaxes.
8 |
9 | As we covered back in the [Installations section](https://www.theodinproject.com/courses/web-development-101/lessons/installation-overview), the front end languages live in the browser so there's no extra installations required. For the reasons listed above, the back end languages do require you to install them on your computer in order to get them running. This should have already been done in that project, so we'll just make sure that you have them properly installed.
10 |
11 | ### Learning Outcomes
12 |
13 | * What the difference between front- and back-end development is
14 | * Why you need to install Ruby but not Javascript
15 |
16 | ### Assignment
17 |
18 |
19 |
20 | 1. Check out [this blog post on back end vs front end programming](http://blog.teamtreehouse.com/i-dont-speak-your-language-frontend-vs-backend) for a quick refresher on the difference between the two.
21 | 2. Read over [this quick interview with Matt Jording](https://generalassemb.ly/blog/what-is-back-end-web-development/) about what back end web development is.
22 | 3. Type `$ ruby -v` and `$ rails -v` into your command line (remember, the `$` just represents the command prompt). You should get back versions similar to `2.0.0` or above and `5.0.0` or above. If you didn't get those values, you'll need to go back to the [Installations Unit](https://www.theodinproject.com/courses/web-development-101/lessons/your-first-rails-application) and get everything installed properly.
23 | 4. You should also be able to use `$ which git` and see the directory where you installed Git.
24 |
25 |
26 |
--------------------------------------------------------------------------------
/web_development_101/the_backend/ruby_basics_lesson.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 |
3 | Our back end focus will be on Ruby, the language designed for programmer happiness. What takes dozens of lines of code in Java or a hundred in C could take just a couple in Ruby because it prepackages lots of sneaky functions into easy-to-use convenience methods.
4 |
5 | Ruby is pretty darn close to Python. In some ways, they sort of resemble romance languages -- once you've learned one, it's not terribly hard to pick up another because they tend to follow many of the same conventions, just using different "words". Python tends to be taught more in colleges and is used a fair bit for more data-intensive and processor-heavy applications.
6 |
7 | But Ruby has a secret weapon that makes it the love of fast-iterating website producers -- the framework Ruby on Rails (which we'll cover in the next section on Frameworks). It has been optimized for being able to write code faster and with less headache, which allows you to iterate more frequently when building a website. By so doing, the end product is more likely to suit the client or the user's needs, making your first mission as an engineer a success.
8 |
9 | With either of the languages, there are a couple of things that aren't immediately intuitive but become very useful when you understand them. These are the quirks and nifty tricks that you didn't see in Javascript.
10 |
11 | In this lesson we'll do a healthy introduction to Ruby and then, later on in the full Ruby course, you'll get to understand it like the back of your hand.
12 |
13 | A final note -- you'll be learning a bunch of new terminology and concepts here but don't think they're only applicable to Ruby. Most of it (like methods, classes, objects etc.) will pop up again in pretty much any other language you ever pick up.
14 |
15 | ### Learning Outcomes
16 | Look through these now and then use them to test yourself after doing the assignment.
17 |
18 | * What is an "interpreted" language?
19 | * What is IRB?
20 | * What are Objects?
21 | * What are Methods?
22 | * What are Classes?
23 | * What are Blocks?
24 | * What is an Array?
25 | * What is an Iterator?
26 | * What are hashes?
27 | * What is a library?
28 | * What is a gem?
29 |
30 | ### Assignment
31 |
32 |
33 | 1. Read through the [Ruby in 100 Minutes](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html) project from Jumpstart Lab. If you can't get IRB running, check out the [Installations Section](https://www.theodinproject.com/courses/web-development-101/lessons/your-first-rails-application?ref=lnav), which you should have done already.
34 | 2. Dive in a little deeper by reading chapters 1-10 of Chris Pine's [Learn to Program](http://pine.fm/LearnToProgram/?Chapter=00). Try to do the exercises at the end of each chapter. Take a crack at chapter 10, but don't feel disheartened if it still doesn't click for you. Answers to the exercises are available at [learntoprogramanswers.blogspot.com](http://learntoprogramanswers.blogspot.com/)
35 | 3. Finally go through the first five sections of [Ruby Monks Ruby Primer book](https://rubymonk.com/learning/books/1-ruby-primer) (up to and including the Hashes in Ruby section)
36 |
37 |
38 | ### Bonus Assignment:
39 |
40 |
41 | Redo the same Project Euler problem that you previously did in Javascript but using Ruby instead (try using IRB or a .rb file that you run from the command line by using `$ ruby ./yourfilename.rb`):
42 |
43 | * [Problem 1: Multiples of 3 and 5](http://projecteuler.net/problem=1)
44 |
45 | Have a go at the next two problems too; feel free to move on to the next lesson though if you find it too challenging. The aim here is to increase your resilience to difficult problems and get you more exposed to how loops and methods are structured:
46 |
47 | * [Problem 2: Even Fibonacci Numbers](http://projecteuler.net/problem=2)
48 | * [Problem 3: Largest Prime Factor](http://projecteuler.net/problem=3) (tip: don't bother for anything over 100,000 doing the brute force solution or you'll need a few days to calculate...)
49 |
50 |
51 |
52 | ### Additional Resources
53 | This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something.
54 |
55 | * Read [Smashing Magazine's Intro to Ruby article](https://hackhands.com/beginners-guide-ruby/) for another good beginner-level treatment of the language as a whole.
56 | * [Ruby on Rails tutor has free videos that include Ruby](http://rubyonrailstutor.github.io/)
57 | * [OverAPI's (dense) Ruby Cheat Sheet](http://overapi.com/ruby)
58 | * Hunter Ducharme compiled together [an e-book](http://hgducharme.gitbooks.io/ruby-programming/) which covers all the basics in Ruby.
59 |
--------------------------------------------------------------------------------