[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Gregory Brown

2/26/2009 1:23:00 AM

== 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_T...

== 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://rubybestpra...

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_i...

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

11 Answers

James Britt

2/26/2009 5:33:00 AM

0

Gregory Brown wrote:
> == 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_T...

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

pat eyler

2/26/2009 5:05:00 PM

0

On Wed, Feb 25, 2009 at 10:33 PM, James Britt <james.britt@gmail.com> wrote=
:
> Gregory Brown wrote:
>>
>> =3D=3D 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_T...
>
> 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
-------------------------
Duty makes us do things, Love make us do things well.
http://on-ruby.bl...
http://eldersjournal.bl...

James Gray

2/26/2009 5:17:00 PM

0

On Feb 26, 2009, at 11:05 AM, pat eyler wrote:

> On Wed, Feb 25, 2009 at 10:33 PM, James Britt
> <james.britt@gmail.com> wrote:
>> Gregory Brown wrote:
>>>
>>> == 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_T...
>>
>> Jump on this. It's great stuff.
>
>
> 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

Gregory Brown

2/26/2009 5:24:00 PM

0

On Wed, Feb 25, 2009 at 8:24 PM, Gregory Brown
<gregory.t.brown@gmail.com> wrote:
> == 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_T...

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

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

-greg

Radoslaw Bulat

2/26/2009 5:48:00 PM

0

On Thu, Feb 26, 2009 at 6:05 PM, pat eyler <pat.eyler@gmail.com> wrote:
> 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... - m=F3j blog

Antonio Cangiano

2/26/2009 6:01:00 PM

0

2009/2/26 Rados=B3aw Bu=B3at <radek.bulat@gmail.com>:
> 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://antonioca... - Zen and the Art of Programming
http://mat... - Mathematics is wonderful!
http://sta... - Aperiodico di resistenza informatica
Follow me on Twitter: http://twitter.com...
Recently completed "Ruby on Rails for Microsoft Developers" for Wrox.

James Gray

2/26/2009 6:37:00 PM

0

On Feb 26, 2009, at 12:00 PM, Antonio Cangiano wrote:

> 2009/2/26 Rados=B3aw Bu=B3at <radek.bulat@gmail.com>:
>> 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 =20
>> 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.

I agree:

http://blog.grayproductions.net/articles/design_patter...

James Edward Gray II=

Gregory Brown

2/26/2009 6:50:00 PM

0

2009/2/26 James Gray <james@grayproductions.net>:
> On Feb 26, 2009, at 12:00 PM, Antonio Cangiano wrote:
>
>> 2009/2/26 Rados=B3aw Bu=B3at <radek.bulat@gmail.com>:
>>>
>>> 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.
>
> I agree:
>
> http://blog.grayproductions.net/articles/design_patter...

I've really been wanting to read that book. It sounds awesome.

-greg

pat eyler

2/26/2009 7:21:00 PM

0

2009/2/26 Gregory Brown <gregory.t.brown@gmail.com>:
> 2009/2/26 James Gray <james@grayproductions.net>:
>> On Feb 26, 2009, at 12:00 PM, Antonio Cangiano wrote:
>>
>>> 2009/2/26 Rados=B3aw Bu=B3at <radek.bulat@gmail.com>:
>>>>
>>>> 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.
>>
>> I agree:
>>
>> http://blog.grayproductions.net/articles/design_patter...
>
> I've really been wanting to read that book. =A0It sounds awesome.

It is pretty awesome. If you want a short taste, here's the interview I
did with Russ:

http://on-ruby.bl.../2008/01/russ-olsen-inte...


>
> -greg
>
>



--=20
thanks,
-pate
-------------------------
Duty makes us do things, Love make us do things well.
http://on-ruby.bl...
http://eldersjournal.bl...

7stud --

2/26/2009 8:31:00 PM

0

Gregory Brown wrote:
>
> 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:

>> A.new
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.








--
Posted via http://www.ruby-....