more thoughts on TFT for those learning to program

8 views
Skip to first unread message

Scharlau, Dr Bruce A.

unread,
Jan 21, 2011, 7:36:57 AM1/21/11
to test-firs...@googlegroups.com

Hi all,

I've now had some time to think through what I intend to try and use and came up with something like the following:

As the current stuff from Sarah and Alex is for those coming at ruby from another programming language that works fine. However, it doesn't work for complete newbies as you need to first explain classes, modules, and strings, multiple files, and other things, which kinda get in the way of even the most simple test that's currently there.

Therefore, I was thinking of trying something like this, which says where they should amend the code, and what they should leave alone. This seemed to be the 'easiest' way I could get something to run using variables in the spec file and also 'rewarded' them by running some other code after they pass all of the tests.

I was thinking that I could do a few more like this for strings, and other things before we get to classes and separate files.

What do you folks think? Have I missed something that might work easier?

Bruce

# spec file for ruby tests
# write your code in the section noted

describe "some ruby numbers" do

before(:all) do
# put your own code here
@myNum = 23
@hours_in_year = 24*365
@minutes_in_decade = 60*@hours_in_year*10

# you should not write anything below this line
end

it "should tell me my number" do
@myNum.should == 23
end

it "should tell me how many hours are in a year" do
@hours_in_year.should == 8760
end

it "should tell me how many minutes are in a decade" do
@minutes_in_decade.should == 5256000
end

# extra exercise to work out
it "should tell me how many seconds old I am" do
# @seconds_old.should == @age_in_seconds
end

after(:all) do
puts # just a blank line to separate output
puts "myNum is " + @myNum.to_s
puts "There are #{@hours_in_year} hours in a year"
puts "There are #{@minutes_in_decade} minutes in a decade"
end


end

The University of Aberdeen is a charity registered in Scotland, No SC013683.

Alex Chaffee

unread,
Jan 21, 2011, 2:25:52 PM1/21/11
to test-firs...@googlegroups.com
Your concerns are well-grounded, but I'm reminded of the motto of
Wikipedia: Wikipedia doesn't work in theory, only in practice. Here
are some possible explanations for my observation that students
without a lot of programming experience still seem to pick up TFT
pretty readily:

* general computer literacy gives people an intuition for multiple
files, source files, and command-line interfaces (e.g. Google Search)
* pairing lets students muddle through together and correct each other gently
* students learn by example, mimicking sample code and tweaking until it works
* classes and functions aren't *that* hard, especially when they
amount to memorized boilerplate syntax
* the first "hello" exercise is very specific and hand-holding
* the exercises are always used in a classroom, with a preliminary
lecture and teachers on hand for one-on-one assistance

Moreover, understanding how to create a new file and write and execute
a complete program is an epiphany in itself; I see no need to postpone
that sense of real power and accomplishment and demystification.

The fill-in-the-blanks technique you described has been used by Ruby
Koans. In my opinion they totally hit the ball out of the park; Ruby
Koans is a beautiful, elegant, and extremely effective way of learning
the language syntax and structures. TFT is supposed to complement
Koans and teach people programming, not syntax.

I have personal experience with the dark side of fill-in-the-blanks
code exercises from my time as a trainer (I don't want to say
"teacher" cause my students were all adults, usually taking a class at
work). I found that students were often confused about where they were
supposed to write their code, and what it was supposed to do, as
opposed to the blank-slate style I developed for TFT. At worst, you've
given the students three problems instead of one: in addition to
writing their own code, they have to figure out where to put it, and
how to conform it to the teacher's now-invisible code (e.g. variable
names and other idiosyncracies of the teacher's personal coding
style).

For example I wouldn't be surprised to see a student make the
following mistake based on your example:

   # put your own code here @myNum = 23

Simple isn't easy! :-)

- A

--
Alex Chaffee - al...@stinky.com - http://alexch.github.com
Stalk me: http://friendfeed.com/alexch | http://twitter.com/alexch |
http://alexch.tumblr.com

Scharlau, Dr Bruce A.

unread,
Jan 31, 2011, 10:01:06 AM1/31/11
to test-firs...@googlegroups.com
Alex,

Thanks for your thoughtful feedback. I've thought it through some more and decided to go with your suggestion and not beat about the bush. I'll go with multiple files, classes, etc from the start and then fill in more details as we go along. This way they learn what's needed, and can do the 'actions' to begin with and then over time we'll fill in the 'why' we're doing it this way part.

Thanks again. I'll keep you'll posted as to how it goes.

--
cheers,

Bruce

Dr. Bruce Scharlau
Dept. of Computing Science
Meston Building, Room 229
University of Aberdeen
Aberdeen AB24 3UE
01224 272193
http://www.csd.abdn.ac.uk/~bscharla
mailto:b.sch...@abdn.ac.uk
Science and Engineering Applicant Day 2011
Wednesday 23 February
For further details, please visit http://www.abdn.ac.uk/applicantday

Reply all
Reply to author
Forward
0 new messages