From: Jonathon McKitrick
Subject: Organizing code with CLOS
Date: 
Message-ID: <1141053683.386495.303240@i40g2000cwc.googlegroups.com>
Do you guys generally put class definitions and generics in one file,
and defmethods in another?  Or lump them all together?

From: Thomas A. Russ
Subject: Re: Organizing code with CLOS
Date: 
Message-ID: <ymifym4aafx.fsf@sevak.isi.edu>
"Jonathon McKitrick" <···········@bigfoot.com> writes:

> Do you guys generally put class definitions and generics in one file,
> and defmethods in another?  Or lump them all together?

Typically I put the class definitions together in one file, and then
organize the methods into files based on their general theme.  So
typically all of the methods for a single generic function would be in
the same file with each other, and with their related methods or support
functions.



-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Kenny Tilton
Subject: Re: Organizing code with CLOS
Date: 
Message-ID: <cpFMf.7013$cF5.4500@news-wrt-01.rdc-nyc.rr.com>
Jonathon McKitrick wrote:
> Do you guys generally put class definitions and generics in one file,
> and defmethods in another?  Or lump them all together?
> 

I do not write defgeneric unless I have to (non-std method combo).

Otherwise, sometimes methods go after their classes, sometimes they all 
go together in a separate file dedicated to a subset of the 
functionality built around the classes.

Elsewhere you asked:

> My current project is steadily growing, and recent interest by potential customers has
> made it pretty clear the growth is going to continue.  I've found myself several times
> readjusting directory layout, filenames, asdf, and so on.

Yes, upheavals are fun.

Learn about pathnames and even <gasp!> logical pathnames. That will let 
you mess with directory structure least painfully.

> 
> Is there a standard approach you have found that works well for organizing (within a
> given module) code according to classes, macros, implementation, misc, utilities, and all
> that?  One that grows well, is easy to maintain, and works well with CL?

Divide the code into packages along whatever sensible functional lines 
you see, the sooner the easier. Each package gets its own subdirectory. 
If you have enough code, this will lead to refactoring because you will 
find using code requiring access to package internals. Not good. So you 
stare at it and extend the API so the using code can stay out of the 
package. Stuff like that.

Classes /must/ precede methods specialized on them, and macros must 
precede any use, so that gives you some clues.

Otherwise, I keep my source files small and just divide up functionality 
along sensible lines of grouping and do not worry about it much.

kt
From: Peter Seibel
Subject: Re: Organizing code with CLOS
Date: 
Message-ID: <m2irr0wzin.fsf@gigamonkeys.com>
Kenny Tilton <·············@nyc.rr.com> writes:

> Jonathon McKitrick wrote:
>> Do you guys generally put class definitions and generics in one file,
>> and defmethods in another?  Or lump them all together?
>
> I do not write defgeneric unless I have to (non-std method combo).

FWIW, I always write a DEFGENERIC, so tastes differ. I typically use
it as a place to document the contract of the GF both for users and
for implementors (i.e. method writers). And I discovered another good
reason for this the other day when wrestling with some code I didn't
write--if you provide an explicit DEFGENERIC it's obvious that all
those methods are part of your code and not part of some library or
framework. (The specific case was I was looking at some code that used
a SAX XML parser and thus had methods defined in order to participate
in the parsing framework and another method that was purely internal
to the code I was looking at. There was no DEFGENERIC for the internal
generic function and consequently it took me a while to figure out
that it wasn't part of the parsing framework.

-Peter

-- 
Peter Seibel           * ·····@gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp  * http://www.gigamonkeys.com/book/
From: Kenny Tilton
Subject: Re: Organizing code with CLOS
Date: 
Message-ID: <S9HMf.5757$uV6.1485@news-wrt-01.rdc-nyc.rr.com>
Peter Seibel wrote:
> Kenny Tilton <·············@nyc.rr.com> writes:
> 
> 
>>Jonathon McKitrick wrote:
>>
>>>Do you guys generally put class definitions and generics in one file,
>>>and defmethods in another?  Or lump them all together?
>>
>>I do not write defgeneric unless I have to (non-std method combo).
> 
> 
> FWIW, I always write a DEFGENERIC, so tastes differ. I typically use
> it as a place to document...

Document? Whassat?

BTW, new release of Celtk (+ Cells LTk) is on the way, possibly as a 
mere sample project within Cells, which is moving to version 3 after 
some nice refinements needed to drive Tk best from a declarative paradigm.

kenny
From: Pascal Costanza
Subject: Re: Organizing code with CLOS
Date: 
Message-ID: <46glscFb423hU1@individual.net>
Jonathon McKitrick wrote:
> Do you guys generally put class definitions and generics in one file,
> and defmethods in another?  Or lump them all together?

The separation into different defclass, defgeneric and defmethod forms 
allows you to organize your code according to the needs of your program, 
and not to the needs of your language. A general rule of thumb to always 
put X and Y together would counter that freedom. Rather, put together 
what belongs together, so to speak. ;)


Pascal

-- 
My website: http://p-cos.net
Closer to MOP & ContextL:
http://common-lisp.net/project/closer/