Austin Ziegler
7/13/2005 11:21:00 AM
On 7/12/05, Luke Worth <luke@worth.id.au> wrote:
>> IMO, classes should -- as much as is possible -- have all of
>> their definition in a single location, using alternate locations
>> only as necessary.
> Righto then, it's just that the function was originally 80 lines
> long and took up room in my editor. its now 30 (original way was
> stupid). If this were c++, i could have had
>
> file a: class x { void process(); }
>
> file b: void x::process() {}
>
> and was wondering if a similar thing is possible with ruby -
> apparently not. Perhaps i need to use an editor that can fold
> methods instead of emacs :P
Sure, it's possible. It's just not necessasrily advisable. In the
case of C++, file A would have been "x.h", and Ruby doesn't really
have the concept of an include file (only a required resource, which
currently maps to a file).
Most of my project files are several *hundred* lines long, but I try
to keep each method as short as possible, and only tend to include
that which is necessary in a given file.
I also tend to treat Ruby a little like Java, defining one "logical"
class per file (like Ruwiki and PDF::Writer), only defining multiple
classes in a file when they are subclasses of Exception related to
the main class of the file. On the other hand, in
Archive::Tar::Minitar, almost everything is defined in a single
class.
-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca