A ruby course

  • Thread starter Brian Schröder
  • Start date
B

Brian Schröder

Hello List,

again I ask for your help. I'm going to give a 16 hours course on ruby
this week, and I've created some slides to aid me with this.
I have to admit that some examples might not be as bright as I wish, and
also there are missing some exercises.
I created the slides in english, such that they can be used by a bigger
part of the community if need should be.

The slides will not cover all that I hope to say in the course, when the
slides have finished I will start with a free experimentation phase
based on my ants sample implementation
http://ruby.brian-schroeder.de/ants/

It would be great if some of you could look at the slides and correct
the language and if somebody comes up with a great example or exercise I
would also be glad for comments.

The slides are located at
http://ruby.brian-schroeder.de/course/

Regards,

Brian
 
J

James Edward Gray II

Hello List,

again I ask for your help. I'm going to give a 16 hours course on ruby
this week, and I've created some slides to aid me with this.

The presentation is looking pretty good. One thing I did notice, on
page 19 and 20, the comments do not reflect the code. You talk about
yield, but use a passed block.

Cover slide looks good! ;)

James Edward Gray II
 
C

Curt Hibbs

Brian said:
Hello List,

again I ask for your help. I'm going to give a 16 hours course on ruby
this week, and I've created some slides to aid me with this.
I have to admit that some examples might not be as bright as I wish, and
also there are missing some exercises.
I created the slides in english, such that they can be used by a bigger
part of the community if need should be.

The slides will not cover all that I hope to say in the course, when the
slides have finished I will start with a free experimentation phase
based on my ants sample implementation
http://ruby.brian-schroeder.de/ants/

It would be great if some of you could look at the slides and correct
the language and if somebody comes up with a great example or exercise I
would also be glad for comments.

The slides are located at
http://ruby.brian-schroeder.de/course/

This is great! Can I add your slides to the WhyRuby? repository
(http://whyruby.rubyforge.org/wiki/wiki.pl?Ruby_Presentations)?

Curt
 
S

STEPHEN BECKER I V

Do you have speaker notes?

If you had 1 to 2 hours to present ruby to a group of people what do
you think would be the most important point to get across? Mind you,
you would need to spend 30- mins on syntax.
Becker
 
C

Curt Hibbs

I noticed a couple of typos:

Page 8: if the situation is not ambigue
should be: if the situation is not ambiguos

Page 11: skript
should be: script

Curt
 
C

Curt Hibbs

Curt said:
I noticed a couple of typos:

Page 8: if the situation is not ambigue
should be: if the situation is not ambiguos

Gee... there's a mistake in my correction! :-(

I should have said...
should be: if the situation is not ambiguous
 
B

Brian Schröder

James said:
The presentation is looking pretty good. One thing I did notice, on
page 19 and 20, the comments do not reflect the code. You talk about
yield, but use a passed block.

Cover slide looks good! ;)

Thanks ;) I really liked this. Even though the unetched one had a better
angle of vision, but the etched ruby is geekier.

Thanks for the comments. In fact there was a problem in my makefiles, I
had fixed this before but the update was not reflected. Guess I have to
learn rake.

I want to link to your sides on the slides homepage to give you the
credits for the image, where should I link to?

regards,

Brian
 
J

James Edward Gray II

I want to link to your sides on the slides homepage to give you the
credits for the image, where should I link to?

If you're worried about it, just include my name. Hmm, unless you want
to use it as an excuse to get more people hooked on Ruby Quiz?
<laughs> Seriously, the image is free. You're under no obligation.
I'm glad it helped.

James Edward Gray II
 
C

Curt Hibbs

Brian said:
Shure, but the final relase will be on sunday after the course has
finished.
Until then I hope the slides will expand a bit more.

Thanks you. If you could just let me know when you then they are ready, I
will add them to the WhyRuby? repository (they can also be updated at any
time).

Curt
 
C

Carlos

It would be great if some of you could look at the slides and correct
the language and if somebody comes up with a great example or exercise I
would also be glad for comments.

Page 7: Ruby follow the principle of least surprise POTS
should be "follows" and "POLS"

Page 8: Function -> Functions
maybe brackets should be omitted on line 7?
maybe you should mark what you type from the program's output? I
thought "hello world" was an example of function calling without brackets :)

Page 9: (I don't follow "often a variable will become a method" (??))

Page 12: ruby -> ruby's (?)

Page 14: in "First program": you don't follow your own advice from page 11
("-w" switch).

Page 15: "entrys" -> "entries" (?)

Page 18: "skope" -> "scope"

Page 19: see page 20

Page 20: Is it a good idea to use 'f' both as method name and the name of
the method's main variable?

Page 21: see page 22

Page 22: similar as above (parameter name 'call' in example of Proc#call)

Page 23: ... I got tired ;)

Nice course. Good luck.
 
G

Gavin Sinclair

Hello List,
again I ask for your help. I'm going to give a 16 hours course on ruby
this week, and I've created some slides to aid me with this.
I have to admit that some examples might not be as bright as I wish, and
also there are missing some exercises.
I created the slides in english, such that they can be used by a bigger
part of the community if need should be.
The slides will not cover all that I hope to say in the course, when the
slides have finished I will start with a free experimentation phase
based on my ants sample implementation
http://ruby.brian-schroeder.de/ants/
It would be great if some of you could look at the slides and correct
the language and if somebody comes up with a great example or exercise I
would also be glad for comments.


p4. Output doesn't fit on page (what I'll call "output overflow").

p7. Output overflow, plu inappropriate full justification of code.

BTW: why can I see "this=is=the=result;nil" all over the place? Yuck.

p8. s/follow/follows/ s/shure/sure/

p10. s/the class/the class./

p12. s/vi/vim/ :)

p13. Prefer a typewriter (monospace) font. *Much* prefer. This goes
for most, if not all, code and output. But *especially* on this
page :)

p14. s/into ri/into irb/

I'll just pause to say that this is a very very very good set of
slides, and attractively presented. Well done.

p16. s/can be used/can be used.../ s/but beware/...but beware/

p19. "map do ... end" reads badly to me, as a matter of style, because
map is not *doing* anything; it's generating a value. So I
prefer to read "map { ... }". I realise you're probably trying
to keep it simple.

p20. You've got room; format line 9 onto three lines for clarity.

p21. Oh, I see. You may not have room. Consider it anyway.

p22. Boring example. Think of something that generates an interesting
result.

p23. s/instanciated/instantiated/ s/n times/n times./
s/longest_string ,/longest_string,/
s/shortest_string/shortest_string,/

p24. s/"/""/

p28. Good exercise. With the Fibonacci generator class, give example
usage and output so students know what they're aiming for. This
will require its own slide.

p29. s/A real application/A Real Application/ (suggestion only)

p31. s/gui/GUI/

p32. Lines 2 and 3 have inconsistent punctuation. Add a period, or
remove one.

(Nice example app, by the way.)

p33. Is it possible to show us a "screenshot" of the application
before launching into improvements?

p34. As per p32.

p36. s/Re raise/Re-raise/

p36. What about plain old "rescue"? (i.e. what does it rescue by
default?)

p37. Slight output overflow. s/running./running/ ?

p38. s/running./running/ ?

p39. Format line 8 on several lines for readability.

p42. s/clients socket/client's socket/
s/clients-thread/the client's thread/

p43. Title case?

p44. "Accessor functions" repeated. "Modules" and "Modules
Exercises": no other outline has this information.

p45. s/propertys/properties/
The "Calculated Property" and "Shortcut" boxes would look better
if their positions were reversed.

p47. s/array like/array-like/g
s/, can be used/ can be used/g
Slight overflow bottom right.

p48. s/christian/Christian/ (I think; I use "given name" anyway.)
The fields and descrptions don't match!!
s/String::split/String#split/

Perhaps you want Person#name -> Name object, with
Name#first and Name#last.
Then Person#age and Person#gender to complete the exercise.

p49. s/no special/not a special/
s/function,/function/
This slide is confusing. You're not demonstrating the ability to
"change classes, functions, modules at runtime".

p50. 0! == 1

p51. Good exercise. How about another?

p52. It would be good to teach extending objects, because it's core to
Ruby, and important when understanding "class methods". But you
can emphasise that it's advanced material, so students needn't be
worried if they don't get it straight away. (It's not *that*
hard to accept, anyway... :)

p53. A comment on line 21 would help: "Includes the AntGame namespace
to this context", or something.

p54. I can't follow this code at a (late night) glance, so I hope
you're explaining it well in person :)

p55. Missing exercises.

p56. Title case?

p57. Again, second-level headings in the section overview are
inconsistent with the early style.


So close, but so tired. I'll review the rest tomorrow. This is a
*brilliant* learning/teaching resource. I'm teaching a couple of
friends Ruby at the moment, and I'll be giving this to them for
self-study.

Cheers,
Gavin
 
B

Brian Schröder

Thanks a lot for the exhaustive list! I'm sorry that I seem to have put
up slides where the formating was broken. I'm just uploading the new
version. (Now including unit testing).

Regards,

Brian
 
B

Brian Schröder

Hello Group,

I need more help.

Gavin said:
p51. Good exercise. How about another?

Anybody has an idea for an exercise on extending existing classes. So
far the only thing I have come up with is:

\exercise{Fibonacci II}{
Extend \codetype{Integer} with a function fib that calculates the
corresponding fibonacci number.}

And my creativity is at an all time low.
p52. It would be good to teach extending objects, because it's core to
Ruby, and important when understanding "class methods". But you
can emphasise that it's advanced material, so students needn't be
worried if they don't get it straight away. (It's not *that*
hard to accept, anyway... :)

Anybody nows of a good example where it is neccessary to extend an
existing object?
I have never used this feature and I don't know when to use it in a
sensible way.
p55. Missing exercises.

Somebody has an idea for an exercise on using modules (as namespace and
mixin?)

A big thanks so far to all the people who have reviewed the slides!

regards,

Brian
 
H

Henrik Horneber

Brian said:
Hello Group,

I need more help.



Anybody has an idea for an exercise on extending existing classes. So
far the only thing I have come up with is:

\exercise{Fibonacci II}{
Extend \codetype{Integer} with a function fib that calculates the
corresponding fibonacci number.}

And my creativity is at an all time low.

Hi!

what about
- extending REXML::Element with a method that strips all unnecessary
whitespaces and all children
- extending String so you can tell it to remove cpp comments /* remove me */

Of course both tasks could be accomplished without extending those
classes. I have no idea in which cases you should write helper methods
and when you should extend existing classes... does anybody have some
'heuristics' or best practices?

regards,
Henrik
 
H

Henrik Horneber

Henrik said:
- extending REXML::Element with a method that strips all unnecessary
whitespaces and all children


make that 'and does that to all children'

sorry :)
 
B

Brian Schröder

Henrik said:
Hi!

what about
- extending REXML::Element with a method that strips all unnecessary
whitespaces and all children
- extending String so you can tell it to remove cpp comments /* remove
me */

Of course both tasks could be accomplished without extending those
classes. I have no idea in which cases you should write helper methods
and when you should extend existing classes... does anybody have some
'heuristics' or best practices?

regards,
Henrik

Hello Henrik,

Sadly I don't want to introduce REXML (even though its a great library).
But this would cost me too much time.

Extending string with something like remove_cpp_comments seems awkward
to me. In any usecase for this I'd rather have a class CppCode that I
can ask to remove_comments. (Or even better, to give me the source
without comments.)

So my personal heuristic tells me not to extend in this case.

thanks for your comment,

Brian
 
M

Markus

Hello Group,

I need more help.

Anybody has an idea for an exercise on extending existing classes. So
far the only thing I have come up with is:

\exercise{Fibonacci II}{
Extend \codetype{Integer} with a function fib that calculates the
corresponding fibonacci number.}

And my creativity is at an all time low.

* Sub class (or extend) array to support "card deck" semantics,
e.g. cut, shuffle, deal, and (*smile*) maybe even stack?

* Add set-like operations to hash (e.g. &&, ||)

* Here's one I find this very useful: add aggregate behaviour to
hashes. For example have { :a=>3, :b=>[0,5,2], :c=>8 } +
{:b=>[7], :c=>4} return { :a=>3, :b=>[0,5,2,7], :c=>12 }

* Add some sort of simple substitution cypher to String

Anybody nows of a good example where it is neccessary to extend an
existing object?

As far as I'm concerned, things like:

def Symbol.intern
self
end

but I don't think that's quite what your asking.
I have never used this feature and I don't know when to use it in a
sensible way.

If you're talking about extending individual objects, the only time
I can recall using it extensively was in a little text based adventure
game. It's kind of odd now that I think about it: I love the ability
but I use it very sparingly.
Somebody has an idea for an exercise on using modules (as namespace and
mixin?)

A linked list or tree package is the semi-standard answer. You can
add it to any class & do "classical" lists & trees. You may want to
note that this isn't very rubyesque thought.
Maybe a simple version history "memento" setup? Or taint tagging
with more history/details than tainted or not? Or some sort of math
package (& use this to introduce Math)?


-- Markus
 
E

Edgardo Hames

Anybody has an idea for an exercise on extending existing classes. So
far the only thing I have come up with is:

Taken from the Design Patterns book, Decorator pattern:

"Attach additional responsibilities to an object dynamically.
Decorators provide a flexible alternative to subclassing for extending
functionality."

You could extend Integer with a fibonacci method, so that you can
write something like:

puts 0.fibonacci > 0
puts 1.fibonacci > 1
puts 5.fibonacci > 5

My 2 cents.
Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top