Breaking up the image

Daniel Vainsencher danielv at netvision.net.il
Tue Dec 10 20:32:53 UTC 2002


It took a few minutes, but IIUC, this is an algorithm to extract
everything else that's needed for running a certain package. Let's say,
a pretty precise view of dependencies.

Are you saying there's a way I can use this particular view of
dependencies backwards, to help me find out all the Traits I can factor
out and make into packages?

Daniel

Anthony Hannan <ajh18 at cornell.edu> wrote:
> Daniel Vainsencher <danielv at netvision.net.il> wrote:
> > Any insights on why these classes know so much
> 
> The general problem is lack of class extensions (traits), as you know.
> 
> > and how to fix it would be most welcome.
> 
> Here's an algorithm that will automatically extract a "minimal" package
> given initial methods.  Its not the best for general factoring, which should
> include more than the bare minimum, but its a start.  It utilizes traits/
> multiple inheritance, but pseudo traits can be used.
> 
> 1. Associate each selector with the lowest common superclass of all
> classes that implement it, but only if that superclass also implements
> the selector itself.  If not, then put the selector in a new trait
> shared by the highest subclasses that do implement it.  For example, the
> selector #asSymbol has four implementors: String, Symbol, Character and
> Vocabulary.  Since their lowest common superclass, Object, does not
> implement #asSymbol, a new trait called CharacterOrStringOrVocabulary is
> created (if not already created before for a similar selector) and
> shared by String, Character, and Vocabulary.  #asSymbol is then added as
> a selector in the trait with "self subclassResponsibility" as its
> method.
> 
> 2. Create a new package.
> 3. Add initial concrete classes that you want included, plus their
> methods you want included (for this algorithm, a class means by itself
> without its associated methods).
> 
> 4. Add concrete classes that package methods reference directly.
> 5. Add selectors that package methods call.
> 6. Add methods of selectors called that are in the hierarchy between
> each selectors associated trait (from step 1) and each concrete class
> already included.
> 7. Go back to step 3 until no more new methods are add.
> 
> The result is a package containing all methods that can possibly be
> called starting from the initial methods, without including selectors
> and their methods that are never called, nor subclasses/superclasses
> that are never used. 
> 
> #perform: is a problem.  Either you have to manually include all
> selectors that can possibly be used by the particular performs included
> in the package, or include all symbols as selectors if you know perform
> selectors are not fabricated at runtime.
> 
> This algorithm also assumes instances will only be created from concrete
> classes referenced.  If this is not the case, as in '(SomeClass allSubclasses
> detect: [:cls | cls someCondition]) new', then they have to be added manually
> as well.
> 
> Cheers,
> Anthony



More information about the Squeak-dev mailing list