I'm reading parts of Michael Fitzgerald's book Learning Ruby. Here's typical crap.
Earlier I referred to x as a local variable. What does that mean? It means that the local variable has a local scope (context). For example, when a local variable is defined inside of a method or a loop, its scope is within the method or loop where it was defined. It doesn't have a useful life beyond that.
There are so many things wrong with this--believe me, I see this all the time.
There's a weird habit where a teacher wants to explain something simple, and ends up referring to something more complex to explain something simple.
Here are a few words, Fitzgerald fails to define: scope, context, loop, method. Finally, he says "doesn't have a useful life beyond that" anthropomorphizing the heck out of local variables.
Does he give an example of a local variable? Does he explain why anyone would want local variables? Does he say what a context is?
He falls into a common trap for programming writers. He explains what is. He doesn't explain why it is. Indeed, I imagine Fitzgerald whining to his editors "Why do I have to explain something so easy?" and then doing a half-ass job.
Technically, there's nothing wrong with his statement (except the horribly vague "doesn't have a useful life after that"), but it's awful nonetheless.
If a reasonable programmer were given the list: local variable, scope, context, loop, method, and asked which was the easiest to explain, I suppose they might pick "local variable". So why on earth would you explain it in terms of the other terms?
And then he refers to duck typing which again is awful. Everyone in Ruby uses the phrase, so he has to stick it in. Did he even define what a type was?
If he assumes we know Java, then he should say "Local variables in Ruby work pretty much like they do in Java". If he assumes that the reader is a programming newbie, this is total dreck.
How did this ever pass an editorial review?
No comments:
Post a Comment