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 K.
on 2006-04-19 17:45
on 2006-04-19 19:45
Uwe K. 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.
on 2006-04-26 02:17
> 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 M. for his writeup. Very useful.