Pre-Course
Today was the final day of our four-week long precourse and it's been a very steep learning curve so far. Now we are prepared to go through our 12-week preparation at Makers Academy to become ace coders with all the hot skills new tech wants. But the pre-preparation didn't begin here.
1 puts "Hello, World!"
2 puts "How original..."
Before we got accepted on the course we had to learn some basic coding and attend an interview that consisted of an informal one-to-one and some pair programming to test what we had learned so far. I thought I failed miserably on the coding part, only knowing the answers to a few of the dozen or so challenges put before us. But as it turns out knowing the answers isn't what's important, it the willingness to communicate, ability to find the answers and acceptance that we won't ever know all the answers.
Since then I have truly come to understand the significance of that statement.
But I digress, so I actually got accepted on the course which thrilled me to bits. I was eager to learn and wanted to get some new high level skills under my belt. After that, the first week of our precourse was to learn the basics of the command-line interface. Terminal on Macs and Bash in Linux. We also had a brief primer on Unix commands and VI.
My hardcore coder friends tell me VI(Visual Interface) is THE BEST! I'm sure it is.
At the end of that week we got a challenge, this is a theme with the course, at the end of most weeks you will get a chance to apply what you've learned during the week. This seems like a very effective way to learn. Learn a bit of theory, put it in to practice right away on the same day, rinse and repeat, then at the end of the weekly cycle you get a much larger and more significant challenge to really get to grips with the knowledge.
The second week was about Github, the popular version-control system. I absolutely fell in love with Git and have become highly addicted to filling those green boxes and keeping up my high-scoring streak of commits.
The weekly challenge for Git was really fun, it included creating, adding, commiting and pushing local files from our terminals up to the origin repo on Git. This obviously after having to initialise the local repo and creating the remote ones and syncing the two up. We also covered checking out, merging, rebasing, branching and bunch of more delicious candy.
The third week is where we started to learn coding proper! It was Ruby week, and it was going to be tough. Materials included Learn Ruby The Hard Way, Ruby Mony, Ruby Kickstart, Codewars, Ruby Koans and more. The weekly challenge was probably our hugest challenge to date, to complete the first two sessions of Ruby Kickstart, if you've ever tried then you might appreciate how difficult this would be for pure beginners to Ruby and to coding.
The fourth and final week was further reinforcement of our Ruby skills, any further time to practice this was and still is very welcome. We had to create a student directory that could, at first, store a hard-coded list of students and allow us to perform menial retrieval tasks on them. Then we set it up so that we could add further values to each student, such as hobbies, cohort, etc. Then we used YAML to to store and retrieve the student directory in a text file. Then we made an interactive CLI interface for users to interact with, to store, retrieve and do all sorts of other amazing things with!
1 require "csv"
2 @students = []
3
4 def print_header
5 print "The students of March 2015 cohort at Makers Academy\n"
6 print "--------------\n"
7 end
8
9 def print_students_list
10 @students.each_with_index do |student, index|
11 linewidth = 30
12 print "#{index + 1}. #{student[:name]} of #{student[:cohort]} cohort".ljust(linewidth)
13 print "#{student[:hobby]} hobby".center(linewidth)
14 print "and COB is #{student[:cob]}\n".rjust(linewidth)
15 end
16 end
17
18 def print_footer
19 @students.length == 1 ? pluralize = "student" : pluralize = "students"
20 print "Overall, we have #{@students.length} great #{pluralize}\n"
21 end
22
23 def input_student_data
24 print "Please enter the names of the student, their cohort, their hobby and country of birth seperated by ',' without any spaces\n"
25 print "To finish, just hit enter twice\n"
26 name = STDIN.gets.strip
27 while !name.empty? do
28 studary = name.split(",")
29 @students << {:name => studary[0], :cohort => studary[1].to_sym, :hobby => studary[2], :cob => studary[3]}
30 @students.length == 1 ? pluralize = "student" : pluralize = "students"
31 print "Now we have #{@students.length} #{pluralize}\n"
32 name = STDIN.gets.strip
33 end
34 @students
35 end
36
37 def interactive_menu
38 loop do
39 try_load_students
40 print_menu
41 process(STDIN.gets.chomp)
42 end
43 end
44
45 def print_menu
46 puts "1. Input the students"
47 puts "2. Show the students"
48 puts "3. Save the list to file (append)"
49 puts "4. Load the list from file"
50 puts "9. Exit"
51 end
52
53 def process(selection)
54 case selection
55 when "1"
56 input_student_data
57 when "2"
58 show_students
59 when "3"
60 save_students
61 when "4"
62 load_students
63 when "9"
64 exit
65 else
66 puts "I don't know what you meant, try again"
67 end
68 end
69
70 def show_students
71 print_header
72 print_students_list
73 print_footer
74 end
75
76 def save_students
77 puts "Enter filename or leave blank to use students.csv"
78 savefile = gets.chomp
79 savefile = "students.csv" if savefile == ""
80 CSV.open(savefile, "a+") do |csv|
81 @students.each do |student|
82 csv << [student[:name], student[:cohort], student[:hobby], student[:cob]]
83 end
84 end
85 puts "#{@students.length} students' data saved in #{savefile}"
86 end
87
88 def load_students(filename = "students.csv")
89 puts "Enter name of file to load from or leave blank to use students.csv"
90 loadfile = gets.chomp
91 loadfile = "students.csv" if loadfile == ""
92 CSV.foreach(loadfile) do |row|
93 name, cohort, hobby, cob = row
94 @students << {:name => name, :cohort => cohort.to_sym, :hobby => hobby, :cob => cob }
95 end
96 puts "Loaded #{@students.length} students from #{loadfile}"
97 end
98
99 def try_load_students
100 filename = ARGV.first
101 return if filename.nil?
102 if File.exists?(filename)
103 load_students(filename)
104 puts "Loaded #{@students.length} students from #{filename}"
105 else
106 puts "Sorry, #{filename} doesn't exist"
107 exit
108 end
109 end
110
111 puts "This program was executed by #{$0}"
112 interactive_menu
Damn, it feels good to be a coder.
Sandi Metz's POODR is high on our reading list too. We have been taught to understand and appreciate Object-Oriented Programming and all the things we're tasked with are to help build on those fundamentals.
By now I've interacted with most of my cohort online and they seem like a really awesome and mixed bunch of people, I think we're going to enjoy this.