basi <basi_lio / hotmail.com> wrote:
> Hello,
> What coding techniques and practices does the expert Ruby programmer
> know and apply? I don't mean being able to program in a some esoteric
> domian (AI, for example) or facility in using various libraries. When
> you look at a Ruby program, what criteria will you use to deem a
> program as written by an expert and another by a neophyte? How does a
> well-written Ruby program look like?

It's not easy to answer: the easy part is the one about Ruby idioms (see 
David's posting for example).  The difficult part is the one about general 
software quality.  There are some rules of thumb but from my experience it 
takes some time and coding experience to become an expert at this (don't get 
me wrong, I don't claim to be an expert in every aspect - I just think I 
prevent certain errors nowadays that I did in the beginning).

The most important part of software engineering is about proper distribution 
of functionality across a software system.  Unfortunately this is often 
quite difficult because when you start out you often won't know what's the 
best way to do certain things.  Often then refactoring or even rewriting is 
the only cure if you have to maintain something or if you have to ensure 
code is maintainable.  A rule of thumb that helps here is to make sure 
methods are not longer than a printer / screen page.

Then of course there's the old strategy to identify nouns in your 
requirement description and make them into classes.  The granularity and 
extent to which you to this depends of course on the project.

Proper naming of classes and variables also helps a great deal.  Although 
it's more tedious to write longer identifiers by hand you'll notice that you 
understand your old code quicker when you see it after seveal months of 
abstinence.

> I am finishing my first Ruby program/system. It works, so far. But it
> looks so ugly that I, myself, will not hesitate to disown it. I'm
> looking for ways to make this ugly duckling show some ruby luster.
>
> A good way to start a new year, I guess.

:-)

Hope I could help at least a bit.

Kind regards

    robert