Forum: Ruby Organizing Ruby code

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4bfcb18ca5298df54d8eb410244d004f?d=identicon&s=25 Uwe Kubosch (Guest)
on 2006-04-19 15:45
(Received via mailing list)
Hi all!

I have now completed two web projects using Ruby On Rails in The Real
World and I am very happy about it.  Woohoo to me!

In RoR all the components have been assigned a location in the project
tree and I find this very helpful.

I am looking for conventions for how to organize business logic that
does not fit easily into the model-view-controller categories.

I guess this is code that goes into the "lib" directory, and it should
be organized like any Ruby code.  The problem is, I have not found any
conventions for how to organize regular Ruby code.

In Java I am forced to have one class per file, the file must be called
the same as the class, and the file should be placed in a directory with
the same name as the package of the class.  These limitations are of
enormous help since it makes finding everything very easy.

Is there something similar for Ruby code?  Should I use modules where I
use packages in Java?  Is there a relationship between module names and
file location?  How many classes per file?  How many modules per file?

Any tips on how to organize Ruby code is appreciated.  I am looking for
a common convention, so that if I follow it, the next Ruby programmer
that comes into the project immediately knows where to find all the
components.

Recommendations for books and websites are always welcome, and so are
any other good sources for information.  On the Ruby/Rails topic I have
read the Pickaxe book, Ruby in a Nutshell, and Agile Programming In Ruby
On Rails.

Any comments on this are appreciated.


Uwe Kubosch
A0ed1bbfe42f4f87e6db0a16706246e2?d=identicon&s=25 Michael Greenly (mgreenly)
on 2006-04-19 17:45
Uwe Kubosch wrote:


I'd recomend looking through the source of other well known projects,
this was what I've done for the most part.  One specific place I'd
recomend looking is in the Rake source code, Rails is another good one.
36194a022cb2afb981bfdf720fc67d82?d=identicon&s=25 Eric Armstrong (Guest)
on 2006-04-26 00:17
(Received via mailing list)
> I'd recomend looking through the source of other well known projects,
> this was what I've done for the most part.  One specific place I'd
> recomend looking is in the Rake source code, Rails is another good one.
>
Hopefully, someone will be nice enough to publish a little
canonical tree when they are done with their investigation.

Craig McClanahan did one for web apps written in Java
that was very helpful. (It was at the Apache site once
upon a time, but I couldn't find it the last time I looked.)

P.S.
Thanks to Stephen Molitor for his writeup. Very useful.
This topic is locked and can not be replied to.