Oct 05
Gather ’round, I’d like to share some strategies for working on the assignments. I could have talked about some of this earlier, but I think now is really the key time, when some of you are 10%, 30%, or 70% done, but not sure how you’re going to get to the finish line.
- The first thing I want to stress is to get some code working first. While the perfect submission for #2 will be a true Ruby one-liner with few or ideally no extra variables, statements, destruction of input data, etc., if you see a solution that has lots of lines, extra variables, go for it: then start refining. “Every block of stone has a statue inside it and it is the task of the sculptor to discover it.” — Michelangelo
- Remember, you’re learning. It’s hard. You are literally building new neural pathways in your brain. Please, drink lots of fluids.
- Yes, I did say that some people would finish in 4 hours. It’s a bell curve. When I took my first serious Java course back in the 1930s, I remember vividly working on it 20+ hours a week, and my code never really completely worked. But fortunately there was partial credit in that class, just like this one. And I learned a lot. I became an expert at making mistakes, and even today I say to Java developers: “Oh, yeah, I did that once.” Amy tells me that while she’s written a lot of Rails code, the concept of the one-liner was a challenge . . . “and look at me now, injecting all over the place!”
- Be a bit self-conscious about your work strategy: If you think you’re more comfortable reading and then doing, try it. But don’t be afraid to reflect on your assumptions and switch things around if you’re not making progress: try alternating reading with doing.
- Remember that the Pickaxe teaches in four different ways: Discursively, about Ruby in general (chapter 2); in an expository fashion for Ruby concepts (chapters 3-9); definitionally, in the chapter on the Ruby Language (chapter 22); and finally, encyclopedically — the API docs for built-in classes and modules (Chapter 27). These different modes tap different ways of understanding. (Someday there will be a Head First book on Ruby and Rails, which will truly try to educate all parts of your brain.)
- One student who shall remain nameless turned in her assignment a few days ago and also shared her strategy for finishing. She went over the lectures, and made a list of capabilities that I presented. Then she went through the assignment, and made a list of “requirements” for each item. Then she matched them up. I think she did this informally, in her head — it was her way of putting her work into a productive order. In many cases, she used the lecture as a way to focus on sections of the Pickaxe. And, of course, she tried everything in irb.
- Rubber ducking (http://compsci.ca/blog/rubber
-ducks-help-best-with-computer -science/) can be very helpful. I happen to have plastic rubber ducks on my monitors, both at home and at work, and I discuss my code with them all the time. - Tossing code and starting over. The idea is that you probably are there conceptually, but your current implementation is messing you up. The classic popular culture example of this is a scene in the movie “A River Runs Through It,” when a boy is essentially being home-schooled by his dad. He writes an essay. The father reads it and strikes words, finally telling the boy that it is better, but that he should tear it up and do it again. What is happening is that the boy is internalizing some ideas about elegance and concision in writing. “Programming is a kind of writing.” — Gerald M. Weinberg
- Do ask questions! If it seems useful for others, Amy or I will post the question and the answer back to the e-mail or to the course site, without attributing the question to you.
Good luck!

October 5th, 2007 at 10:45 pm
Thanks for the tips! They are much appreciated! and say hi to the duck.
October 7th, 2007 at 5:27 pm
How do we deal with the following irb> behavior…?
As I enter expressions into irb, I frequently get ’stuck’ when I enter an expression where ruby wants ‘more.’ Then, the irb prompt goes from xxx.0> to xxx.1> and nothing I enter will complete the statement! I often have to just close the entire terminal session and start a new session. How do I cancel, if I can’t figure out what the ruby evaluator needs?
Example:
OK after exception…
irb(main):011:0> a.partition { |name| name.to_s.slice(0) == ‘A’ }
=> [[], [”John”, “Amy”, “Jim”, “Naomi”, “Aaron”, “Zack”]]
irb(main):012:0>
STUCK after bad statement!
irb(main):030:0> ‘Frank’.slice(0).to_char
NoMethodError: undefined method `to_char’ for 70:Fixnum
from (irb):30
from :0
irb(main):031:0> ‘Frank’.slice(1)
=> 114
irb(main):032:0> ‘Frank’.slice(2
irb(main):033:1> ‘Frank’.slice(2)
irb(main):034:1>
irb(main):035:1*
irb(main):036:1>
irb(main):037:1*
irb(main):038:1* q
irb(main):039:1>
irb(main):040:1* a = [”John”, “Amy”, “Jim”, “Naomi”, “Aaron”, “Zack”]
irb(main):041:1> a
irb(main):042:1> a
irb(main):043:1>
October 7th, 2007 at 7:54 pm
Lee: Press control C to escape.