Classes as Packages (was: Harvesting infrastructure)

danielv at netvision.net.il danielv at netvision.net.il
Mon Nov 18 18:11:31 UTC 2002


I agree. Spaghetti Tracer is meant to do this sort of analysis,
presenting results to humans. Basically, my starting point was the same
as a statement Hannan made - we shouldn't have to declared dependencies,
the code does.

Then I also suddenly noticed, we don't have to declare packages, either,
the code does that too. Let me explain - a class can be unloaded if it
is referenced by nothing. A set of classes can be unloaded if it is
referenced by nothing outside itself. These are the things that are
strictly on "top" of the basic image stuff. Let's call them "topping",
like the strawberries in a cake. By "basic" I mean they're referenced by
everything, and will never be unloaded (like Object). 

Our problem with unloading is when something that should be unloadable,
because it should be part of the topping, is actually referenced by
something in the base. Fortunately, this is automatically detectable.

Because all the topping references the base, anything that should be in
the topping but is in the base, implies a circular dependency, which is
the basic no no of modules (Since modules supposed to create a
hierarchy). In fact, that's the definition of the "base" - everything in
a circular relationship with Object, direct or otherwise.

That's computed by Spaghetti Tracer detects.

All of the above doesn't mean we *shouldn't* declare packages - they're
very useful to override the "natural" structure for design reasons, for
example, to define class extensions, and also to "summarize" the
structure for us capacity limited humans. It just means that packages
are not arbitrary, there's a natural rule they should obey - it can be
no bigger than any circular dependency it touches...

Daniel

Andreas.Raab at gmx.de wrote:
> > I've been thinking of writing a tool for automatically carving
> > out the image that uses a greedy algorithm based on this - for each method
> > that depends on a package, would it increase or decrease the number of
> > external references by pulling the method into the package?  After a
> > number of iterations, my guess is that you'd end up with a fairly good
> > definition of the package (this is similar to what Anthony was describing,
> > but I believe the final lines need to be drawn by humans, not
> > algorithms - there's extra semantic content we can add through
> > categorization that automated dependencies cannot).
> 
> I'd say give the information to the human to begin with. The process will in
> almost all cases not converge (I tried it) trivially and if you get across a
> certain point you'll end up with everything. The critical point is usually
> easy to detect for humans but not automatically.
> 
> Cheers,
>   - Andreas
> 
> -- 
> +++ GMX - Mail, Messaging & more  http://www.gmx.net +++
> NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!



More information about the Squeak-dev mailing list