[ANN/ADV] Sample Chapter from "Ruby Best Practices"

G

Gregory Brown

== The short story

Hi folks, I bugged O'Reilly to let me release a sample chapter of my
book, and they let me.

So you can now directly download a PDF copy of my "Mastering the
Dynamic Toolkit" chapter without having to go through any hoops:

http://cachefly.oreilly.com/catalogs/Mastering_the_Dynamic_Toolkit.pdf

== For a little background on RBP:

This book is aimed mostly at people with a decent technical grasp of
Ruby but not a ton of practical experience. The goal is to show how
to attack Ruby problems in the way that a seasoned Rubyist might.
Though it might not be suitable for raw beginners, intermediate Ruby
programmers should be able to learn a lot from the book, and strong
Ruby programmers should *enjoy* it. I've put together a great
internal review team to help me make sure I reach this goal, and we
also have Rough Cuts set up for general feedback.

== For a little background on this chapter

In the PDF I linked above, you'll find all sorts of meta-programming
and DSL goodness, if not by name. I try to emphasize how much these
'voodoo' like features can be treated like ordinary Ruby code if you
take some care to do things well.

I chose this chapter to release because it's my favorite. Most of the
other chapters in the book follow the same general format, though.
That means if you like this one, you'll probably enjoy the others as
welll.

== Please help me improve the book!

I still have a few weeks to make revisions, so whether you plan on
buying the book or not, feel free to offer some feedback. I've also
made an agreement with O'Reilly to allow me to release the book under
a creative commons license 9 months after publication.

If after reading the chapter you decide you want to see the whole
thing and offer some suggestion before it goes to print, please buy a
rough cut:

http://rubybestpractices.com

If you want to know exactly what's in the book, you can check out this
blog post:

http://blog.majesticseacreature.com/archives/2009.02/whats_in_rbp.html

Anyway, I'll spam the list only twice more, when the book reaches
content completeness (in a few weeks), and when it goes to print
(hopefully in June). I hope you enjoy it!

-greg
 
J

James Britt

Gregory said:
== The short story

Hi folks, I bugged O'Reilly to let me release a sample chapter of my
book, and they let me.

So you can now directly download a PDF copy of my "Mastering the
Dynamic Toolkit" chapter without having to go through any hoops:

http://cachefly.oreilly.com/catalogs/Mastering_the_Dynamic_Toolkit.pdf

Jump on this. It's great stuff.

--
James Britt

www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff
 
P

pat eyler

Jump on this. =A0It's great stuff.


Seconded, I've seen several of the chapters and talked with Gregory
about this and it's quality.

Ruby books haven't been doing well of late (sales are down 51%
over last year), so it's good to see a good book that the community
can get behind. Maybe this will help reverse the trend.


--
James Britt

www.jamesbritt.com =A0 =A0 =A0 =A0 =A0 - Playing with Better Toys
www.ruby-doc.org =A0 =A0 =A0 =A0 =A0 =A0 - Ruby Help & Documentation
www.rubystuff.com =A0 =A0 =A0 =A0 =A0 =A0- The Ruby Store for Ruby Stuff



--=20
thanks,
-pate
 
J

James Gray

Seconded, I've seen several of the chapters and talked with Gregory
about this and it's quality.

Agreed. It's been a great project to be an early reviewer on.

James Edward Gray II
 
G

Gregory Brown

== The short story

Hi folks, I bugged O'Reilly to let me release a sample chapter of my
book, and they let me.

So you can now directly download a PDF copy of my "Mastering the
Dynamic Toolkit" chapter without having to go through any hoops:

http://cachefly.oreilly.com/catalogs/Mastering_the_Dynamic_Toolkit.pdf

I forgot to mention that for the twitter inclined, you can find book
announcements at:
http://twitter.com/rubypractices

Now I'll really stop with the self-promotion :)

-greg
 
R

Rados³aw Bu³at

Ruby books haven't been doing well of late (sales are down 51%
over last year), so it's good to see a good book that the community
can get behind. =A0Maybe this will help reverse the trend.

Mu guess is that there are too many books that describe only ruby (as
a language) and rails (I'm pretty sure that there are more books about
rails than ruby itself... - it's paradox :)). Gregg's books should be
shiny gem in ruby books land.

--=20
Pozdrawiam

Rados=B3aw Bu=B3at
http://radarek.jogger.pl - m=F3j blog
 
A

Antonio Cangiano

2009/2/26 Rados=B3aw Bu=B3at said:
My guess is that there are too many books that describe only ruby (as
a language) and rails (I'm pretty sure that there are more books about
rails than ruby itself... - it's paradox :)). Gregg's books should be
shiny gem in ruby books land.

IMHO, "Design Patterns in Ruby" by Russ Olsen is another shiny gem.

Cheers,
Antonio
--=20
http://antoniocangiano.com - Zen and the Art of Programming
http://math-blog.com - Mathematics is wonderful!
http://stacktrace.it - Aperiodico di resistenza informatica
Follow me on Twitter: http://twitter.com/acangiano
Recently completed "Ruby on Rails for Microsoft Developers" for Wrox.
 
7

7stud --

Gregory said:
This book is aimed mostly at people with a decent technical grasp of
Ruby but not a ton of practical experience. The goal is to show how
to attack Ruby problems in the way that a seasoned Rubyist might.

I have just about 0 technical grasp of ruby, but so far I can understand
everything in your example chapter. I did have to look up a few things
in pickaxe2.

== Please help me improve the book!

I still have a few weeks to make revisions, so whether you plan on
buying the book or not, feel free to offer some feedback.

Ok, here goes.

1) In this sentence:

"Builder works by capturing calls to missing methods, but if a method is
actually defined, it’d have trouble doing its magic."

The contraction "it'd" is awkward and rarely used in conversation or in
writing. Substitute "it would" instead.

2) This sentence:

"For example: if XmlMarkup were just a subclass of Object, with no
methods removed, you wouldn't be able produce this XML, due to the
naming conflict."

The phrase 'this XML' had me looking up--instead of down. It would be
clearer to me if the sentence was changed to this:

"For example, if XmlMarkup were just a subclass of Object with no
methods removed, you wouldn't be able produce **the following** XML due
to **a** naming conflict."


3) Error here:

"The technique used here is simply to initialize a hidden_methods hash
within the class, and then assign **then** method name as a key to the
associated UnboundMethod object."

That seems to be a common error in the text. You should do a search for
'then' to find similar errors.

Also, the "a @hidden_methods" phrase is awkward. An alternative:

"The technique used here is simply to initialize a method named
@hidden_methods with a hash..."

I think the phrase 'within the class' is redundant, so that could be
eliminated to make the sentence approximately the same length.

4) I found this confusing:
NoMethodError: undefined method `inspect' for #<A:0x42ac34>
...
Maybe IRB bug!! <-----***

You use "Maybe IRB bug!!" in several places, and it doesn't add anything
explanatory to the output--quite the contrary. I found it confusing.

5) I found the following example more confusing than what it was trying
to explain:

-----
Think of this as a much higher-level version of simple temporary
state modification that mirrors this structure:
x = 10 => 10
old_x, x = x, nil => [10, nil]
x.nil? => true
x = old_x
=> 10
---------

I think the parallel assignment makes it hard to track what's going on.
If the reader is such a beginner that you need to spell out how to save
a value and then later restore it, how about doing it with absolute
crystal clarity(which in my opinion can't be done with irb output):

x = "hello"
old_x = x

x = 30
puts x #30

x = old_x
puts x #"hello"

Personally, I think the original explanation was clear enough, and this
example should be binned.
 
G

Gregory Brown

I have just about 0 technical grasp of ruby, but so far I can understand
everything in your example chapter. =A0I did have to look up a few things
in pickaxe2.

That's great. If you can read this chapter with a reference to dive
into when you need it, then you'll have no trouble with the whole
book. My disclaimer is mostly because I don't make any effort to
include 'beginner ruby' content, but it may not be as difficult to
approach as I make it sound for those who are willing to look things
up.
Ok, here goes.

For the grammatical corrections, I'll make all of them. I should have
put a disclaimer that this hasn't gone through O'Reilly's proofreaders
yet, only the internal tech review team I set up. So the typos and
bad grammar are all my fault, and will be corrected before we print,
hopefully. Of course, those who have signed up for roughcuts or read
this free chapter are still encouraged to point out these issues. The
more I fix before I hand the draft over, the better.
4) I found this confusing:

NoMethodError: undefined method `inspect' for #<A:0x42ac34>
...
Maybe IRB bug!! =A0 <-----***

You use "Maybe IRB bug!!" in several places, and it doesn't add anything
explanatory to the output--quite the contrary. =A0I found it confusing.

It's part of the actual irb output, so that's just verbatim copying,
not added commentary. I agree though. Take it up with ruby-core :)
5) I found the following example more confusing than what it was trying
to explain:
I think the parallel assignment makes it hard to track what's going on.
If the reader is such a beginner that you need to spell out how to save
a value and then later restore it, how about doing it with absolute
crystal clarity(which in my opinion can't be done with irb output):

You're right... I shouldn't be expecting the reader to not have this experi=
ence.
Personally, I think the original explanation was clear enough, and this
example should be binned.

So, actually... there are more than a few cases where an internal tech
reviewer pointed something out, and I said "If a reader points this
out, I'll make the change". This is one of them. Consider that
example slashed.

Thanks for the great feedback.

-greg
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top