Ruby Black Belt


#1

Hello Ruby community!

Do You want to take part in the creation process of exam series,
covering Ruby itself and RoR framework?

Those who are familiar with Java may have noticed the place on the web
called JavaBlackBelt.com. JavaBlackBelt is a community for Java & open
source skills assessment. Everybody is welcome to take existing and
build new exams.

Until now only Java and related technology exams were available over
there. In the recent feature it is planned to expand existing content
with a set of Ruby related exams.

The first step of exam creation is to define an exam objective and
question categories. This first step was accomplished and a draft
version is available right here:

http://www.javablackbelt.com/WikiPage.do?action=view&page=ExamRuby

The goal of objective is to define a Ruby knowledge boundaries needed
to pass the test. The content will be created according to stated
question categories.

What we need is a feedback of experienced Ruby enthusiasts (means You).

Please tell what do You think of the question categories. Are they too
complex or too simple for Basic level exam? May be there is statements
that are not easy to understand or they are just totaly wrong? May be
some topics should not be included in basic level, may be some new
added?

P.S. I will post here a message when the process of exam creation will
be started and everyone will have a change to add a tricky questions
and take the exams.

Dmitry


#2

Dmitry B. wrote:

Until now only Java and related technology exams were available over
to pass the test. The content will be created according to stated

P.S. I will post here a message when the process of exam creation will
be started and everyone will have a change to add a tricky questions
and take the exams.

Dmitry

What’s the purpose of the exam? There was a thread a while back[1] where
most people expressed a strong dislike for anything resembling Ruby
‘certification’.

[1]http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/163911?163839-166046

-Justin


#3

On Mar 28, 2006, at 3:08 PM, Dmitry B. wrote:

Do You want to take part in the creation process of exam series,
covering Ruby itself and RoR framework?

Not really, but I doubt you want to hear that. :wink: So, I better at
least point some things out. From your basic exam:

Vocabulary and concepts (1 questions)

Ruby source file supposed to have .rb extension.

While this is good practice, it is certainly not required. There are
even times it would be considered undesirable (making a command-line
executable, for example).

Understand that basic commands like puts and exit are actualy
Kernel class methods.

They are actually Kernel instance methods.

Ruby Environment (1 question)

Know that RUBYPATH contains a list of directories to look for
included files.

This variable is not set on my system, just FYI.

Naming (3 questions)

Ruby naming style and how it affects code

* Constants: UPPER_CASE
* Classes: Starting with uppercase

…at each new word: LikeThis.

* Methods and variables: starting with lowercase

…and using underscores to separate words: like_this.

Know that methods ending with ! are supposed to be mutators (sort!).

Actually, they are considered dangerous. exit!() is not a mutator,
for example.

Comments (1 question)

Know that the Ruby code has a # (sharp) comment symbol.

…and multi-line comments:

=begin
This is a comment.
=end

Variables (2 question)

Know that there is no unbound variables, but only class attributes.

What does this mean?

Know that it is not necessary to define staring value in Ruby. It
is nil.

You will probably get a warning for programming like this though, if
Ruby’s warnings are on.

Know how to check if variable is defined with nil? method.

You check if a variable is nil with nil? and defined with defined?.

I/O (2 questions)

IO reading iterators: each_line

Or its alias: each().

Classes (3 questions)

Know that the name of constructor method in Ruby is ‘initialize’.

The name of Ruby’s default constructor is new(). The name of the
method new() calls to complete object construction is initialize().

Understand that class methods are supposed to work without any
object being created.

That’s a little more fuzzy in Ruby than Java, since the class itself
is an object.

Know that Ruby does not care what is the class name of the object
until it has called methods.

What does this mean?

Methods (2 questions)

Know what does method ‘alias’ means in Ruby.

alias is a keyword, not a method.

Blocks (1 question)

Usage of blocks and iterators.

These are two pretty broad topics that probably should not be lumped
together under one topic.

Not covered: creating own iterators and using ‘yield’.

yield is used to call a block. That might be to create an iterator,
but it does not have to be.

Exceptions (2 questions)

Know that Exception is a class and custom exceptions should inherit
it.

I believe most custom exceptions should inherit from RuntimeError.

‘catch’ and ‘throw’ constructs.

Why are these here? They have nothing to do with exceptions.

Modules (1 question)

Understand the difference between require and load commands.

This is not related to modules.

Know that it is not mandatory to include file extension in ‘require/
load’ directives.

Again, nothing to do with modules.

Dynamic usage of load command.

Again.

James Edward G. II


#4

…and multi-line comments:

=begin
This is a comment.
=end

Really? Splendid, thanks :slight_smile: See - this is useful.

Know that it is not necessary to define staring value in Ruby. It
is nil.

You will probably get a warning for programming like this though,
if Ruby’s warnings are on.

And class scope variables - they don’t default to nil.

Know that Ruby does not care what is the class name of the object
until it has called methods.

What does this mean?

Dynamically typing?


#5

On 28 Mar 2006, at 23:03, Jeppe J. wrote:

Hey if people is against an exam, why not make it more like a test
so that
people and especially newbies (like me!) would know on which areas to
improve themselves?
I’ve seen such a test for C++, and I thought it was a really great
tool.

If you’re not aware of it, you may get a lot from: http://
www.rubyquiz.com/

Certainly, the language tests I’ve done have seemed to be a terrible
representation of my abilities (and I’m not just bitter about being
bad at them, as I’ve generally done well :). For instance, in c++,
they’d generally ask lots of ridiculous detail about totally obscure
sections of the language (oooh, bit fields, and exactly what happens
when you do all sorts of things that any good book will strongly warn
you against - basically, questions that if you need to know the
answer to, you’re almost certainly doing something in an
inappropriate manner). At the same time, they tend to miss out on
more useful things like “do you know what the STL and Boost are, and
why they’re good”.

I think everyone I know with any kind of “official” certification for
being competent with a technology believes it to be a total waste of
time. Useful for getting the odd job, but otherwise pointless.

:slight_smile: But I’ve got to say, I’m not sure why I have an irrational dislike
of the idea of Ruby certification. Maybe a simple one would be having
a gem up on rubyforge :slight_smile: And your “score” could be the number of
downloads it gets :slight_smile: So I’m a zero and a zero so far…


#6

Hey if people is against an exam, why not make it more like a test so
that
people and especially newbies (like me!) would know on which areas to
improve themselves?
I’ve seen such a test for C++, and I thought it was a really great tool.

2006/3/28, Dmitry B. removed_email_address@domain.invalid:


#7

On 3/28/06, Dmitry B. removed_email_address@domain.invalid wrote:

Hello Ruby community!

Do You want to take part in the creation process of exam series,
covering Ruby itself and RoR framework?

No. For the reasons others have mentioned. Public mailing lists are
a better way to learn, and any test to ‘measure your skills’ will
surely be missing some important things and have some unnecessary
things.


#8

Jeppe J. wrote:

Hey if people is against an exam, why not make it more like a test so that
people and especially newbies (like me!) would know on which areas to
improve themselves?
I’ve seen such a test for C++, and I thought it was a really great tool.

Want to get better at Ruby? Help answer questions on ruby-talk.

People ask all sorts of stuff, from the simple to the sublime.

When a question comes up, offer an answer.

See, if you take a test in private, you can be a major doofus and no one
need know. But if you try answering questions in public, then the
pressure is on; few things sharpen the mind like fear of public
ridicule.

Actually, few people get ridiculed here. But if you are wrong, people
will point it out; so you either confirm you knowledge, or expand it.

Far better than any test.

Want a certificate? Tell people to Google “Ruby+#{your_name}” and judge
for themselves.


James B.

“In Ruby, no one cares who your parents were, all they care
about is if you know what you are talking about.”

  • Logan C.

#9

On 3/28/06, Gregory B. removed_email_address@domain.invalid wrote:

No. For the reasons others have mentioned. Public mailing lists are
a better way to learn, and any test to ‘measure your skills’ will
surely be missing some important things and have some unnecessary
things.

I agree with James B.'s and Gregory’s assessments. I know I’ve
learned a lot more from answering questions on this mailing list than
I would from studying for and taking some exam. I think the whole
certification/exam thing fits in more with a very corporate
environment, like you find in the Java community. I know Rails has
drawn a lot of attention to Ruby from the corporate world, but I’d
prefer to keep the nice community spirit we have and not get too
sucked into the corporate environment, at least as far as culture is
concerned.

With that said, there is nothing stopping people from making exams or
certifications for Ruby, but frankly they won’t mean much without the
support of the community. Plus it is very important to have Ruby
experts involved otherwise the exam itself may not even be accurate
(as James Edward G. II illustrated earlier in this thread.) That
situation is worse than have no exam at all…much worse.

Ryan


#10

On Mar 28, 2006, at 6:28 PM, Gregory B. wrote:

On 3/28/06, Dmitry B. removed_email_address@domain.invalid wrote:

Hello Ruby community!

Do You want to take part in the creation process of exam series,
covering Ruby itself and RoR framework?

No. For the reasons others have mentioned. Public mailing lists are
a better way to learn, and any test to ‘measure your skills’ will
surely be missing some important things and have some unnecessary
things

And some of us consider the creation of a certification as the
hallmark that a language is undergoing the process of dilbertization.
Sorry to be so blunt, Dmitry.


Jason P.
removed_email_address@domain.invalid

“The computer allows you to make mistakes
faster than any other invention, with the
possible exception of handguns and tequila.”


#11

Yeah I could do that, but this is my first language and I can still only
answer basic questions.

2006/3/29, James B. removed_email_address@domain.invalid:


#12

Just set it up and if some people find it useful, then so be it. You
don’t
need approval from anyone.


#13

First of all want to thank all of You who posted comments here. Special
thanks to James Edward G. II for pointing at the misstakes,
incompleteness and obscure language!

When I have posted at Ruby group I have expected far more “blunt”
relpies, believe me :wink:

Now allow me to try to ‘defend’ myself a bit :slight_smile:

What we are talking here about is a bit different, than traditional
certification. The main purpose is learning. You pass the exam and see
that You don’t know some answers. After the exam it is possible to see
the explanation and to learn (multiple-line comments is realy a good
example :slight_smile: ) As I have mentioned before, everyone will be allowed to
add new questions and the best of them will be chosen by approval
process. No single no-expert person (like me) is going to create a set
of questions and call it a certification. I will be posting mine and
humbly waiting for other Ruby specialists to rate or comment it. And of
course public mailing list and practice ARE better ways to learn :slight_smile:

And tell me one more thing - why some of You afraid of Ruby becoming
popular?

Dmitry


#14

Dear all,

Enumerable#select always returns an array. On a hash too, it returns
an array of arrays of key-value pairs.

The issue with this approach is that ‘select’ calls cannot be chained.
It is now mandatory to know whether the receiver is the original hash
or is the result of at least one ‘select’.

Thus, for 'select’ing a second (or subsequent) time, the semantics of
the block themselves have to change.

Else, the result of the first selection has to be manually converted
to a hash (may be using something like hsh =
Hash[select_result.flatten]).

Is there some reason why when a filter is applied to a hash, we get an
object of a different type?

This is not so much an issue, semantically, with Set instances, though
the principle applies there, as well.

Wouldn’t it be good if application of a filter on an object of a given
type results in an object of the same type?

Best regards,

JS


#15

Srinivas J. schrieb:

Enumerable#select always returns an array. On a hash too, it returns
an array of arrays of key-value pairs.

Right.

The issue with this approach is that ‘select’ calls cannot be chained.
It is now mandatory to know whether the receiver is the original hash
or is the result of at least one ‘select’.

It works for me:

h = { 0 => 0, 1 => 2, 2 => 3, 4 => 4 }

h.select { |k,v| k % 2 == 0 }.select { |k,v| v % 2 == 0 }

=> [[0, 0], [4, 4]]

Can you show us your problem?

Regards,
Pit


#16

Srinivas J. wrote:

the block themselves have to change.

Else, the result of the first selection has to be manually converted
to a hash (may be using something like hsh =
Hash[select_result.flatten]).

Is there some reason why when a filter is applied to a hash, we get an
object of a different type?

I’ve stumbled on the same issue yesterday and was a bit miffed, mostly
because I couldn’t have Hash#select! , while I can do Hash#reject!
A simple reversal of logic did the trick, but the question remains.
Cheers,
V.-

http://www.braveworld.net/riva


#17

Thank you for pointing out the chained ‘select’!

Allow me to apologize for the incorrect problem statement.

The issue is actually not with downstream 'select’s, but with other
calls that assume a hash-like behaviour on the part of the container.

Examples include Hash#[] and Hash#each_value.

Should I choose to use these calls somewhere, I need to first know
whether the container I have been passed is the original hash or the
result of at least one ‘select’.

The matter is confusing since Hash#reject actually returns a hash!
Yes, Hash#reject is equivalent to Hash#delete_if on a ‘dup’ of self.
But, semantically, the exclusion filter on the hash is returning a
hash again, while the inclusion filter is not!

I hope this explains my question better.

Best regards,

JS


#18

On Wed, Mar 29, 2006 at 05:40:54PM +0900, Srinivas J. wrote:

Thank you for pointing out the chained ‘select’!

Allow me to apologize for the incorrect problem statement.

The issue is actually not with downstream 'select’s, but with other
calls that assume a hash-like behaviour on the part of the container.

Examples include Hash#[] and Hash#each_value.

It’s not pretty but…:

h = { 0 => 0, 1 => 2, 2 => 3, 4 => 4 }
=> {0=>0, 1=>2, 2=>3, 4=>4}

Hash[*h.select { |k,v| k % 2 == 0 }.flatten].each_value {|v|
p v}
0
3
4
=> {0=>0, 2=>3, 4=>4}

marcel


#19

On Mar 29, 2006, at 12:31 AM, Jeppe J. wrote:

Yeah I could do that, but this is my first language and I can still
only
answer basic questions.

We all started there my friend. How do you think we got better? :wink:

James Edward G. II


#20

Dmitry B. wrote:

certification. The main purpose is learning. You pass the exam and see
popular?

Dmitry

Hello all,

I am just learning Ruby, new to the mailing list/Ruby world so plz no
bashing (especially because I am partially on Dmitry’s side ;-).
Currently i am a professional Java/J2EE coder, for the last 5 years.
I have picked up Python about 2 years ago, and fell in love with it
immediately. I have found much more productive, effective, quick and
mainly fun way of developing SW.
However, some weeks ago gave Ruby a try (I did know about Ruby for
years, but i said Python is essentially just the same with different
syntactic sugar, so why waste time to learn the same thing twice) - but
now, to say the least i am really happy that i did sacrifice some time
to read the pickAxe. Just now i am thinking about switching to Ruby from
Python.

Why i am writing this? Because i remember having exactly the same debate
on the python-tutor list. Somebody asked for some kind of python
certificate, and got crushed by several guys in matter of minutes. What
was even worse there, they did not even explain him what they do not
really like about such a certificate.

Believe me, I can absolutely understand your points. I do not like to
work in Java at all, it is obscure, not suited for creative thinking,
byrocratic, overcomplicated (With my pythoninc friend who dislikes java
too, we designed once a tutorial for absolute beginners: You had to
install HelloWorldFramework where you only had to implement IHelloWorld
interface to get started to write your first ‘Hello World’ app :wink: .

Unfortunately at my current company we are doing something big and it is
not possible for us to switch to python/ruby, and as i am interested in
the solution we are developing, i have to stick with Java, despite my
disgust. Of course i do not like it’s certificate approach, which values
lexical knowledge of idiotic obscure language details over natural
talent/creativity (which is hard to measure anyway).

But still, I can understand Dmitry’s point as well. I believe (hope) he
is looking for a different facet of a ‘certificate’ (probably the word
‘certificate’ is flawed right away) than a test which certifies you are
a good/bad ruby programmer. I can summarize this feature in one URL:

http://www.pythonchallenge.com/

I also solved the python challege up to level 20 or something when it
got too time consuming. To sum it up: to get to the next level you
needed to apply some python technique/module (like regexps, loading a
web page, IO, gfx, GUI, etc) and it was gradually getting harder and
harder. The catch was, that even the non-programmers rushed to learn to
program - because there was no other way around to get to the next level
and because you wanted to get to the next level badly (it was kinda
addictive). When the next level came up, it was immediately clear that
you are missing info on this or that technique/module/feature of the
language.

I know that the ruby-quiz is around, and i think it is a great idea - i
hope i will manage to find some time to play around with it. However,
what was different in the case of the python challenge: it was
hierarchical, and in a very natural yet funny way it somehow certified
your skills in python/programming (i.e. if you got yourself to level X,
you had some experience with regexps, IO, web, UI, …). I think this is
the kind of certificate which would be interesting to see in Ruby as
well - and not the Java style experience-with-obscurity-is-knowledge
style crap.

peter