The more I write Smalltalk in VW the more I'm bothered with my domain
vocabulary being 'taken' by the Smalltalk namespace.
Such simple things as modeling a Message or a Model too often gives me
the jarring experience of the name being 'taken'.
So what imports do we actually use in code?
I started to play in new namespaces _without_ any imports and started to
import only specific names instead of using 'Smalltalk.*'.
This led to the surprising result that domain models often need less
than 5 specific imports from outside the Soops namespace hierarchy.
Here is a little analysis script that measures uses of non-Soops names
from methods inside Soops namespaces.
I only measure references from methods because references for the
purpose of subclassing do not use the import mechanisms.
ns := Soops.
refsByNamespace := Dictionary new.
refsByPackage := Dictionary new.
[:class :sel :compiled |
compiled literals do:
ifTrue: [lit binding environment notNil]
ifFalse: [lit isBindingReference and: [lit isDefined]])
[(lit binding absoluteName
startsWith: ns absoluteReference path)
[(refsByNamespace at: class
environment ifAbsentPut: [Set new])
add: lit binding.
(refsByPackage at: class
package ifAbsentPut: [Set new]) add: lit binding]]]].
It turns out that in our code there are many packages that only use a
handful of names from the libraries.
We already have the option to set a 'default namespace' on a package (to
allow resolutions unrelated to the imports of a class we might be
My experiments suggest that we do not need a default namespace on
packages but rather that we need to go one level deeper and have a
'default imports' section so I can declare the handfull of names the
package references instead of all-of-cincom-smalltalk.
vwnc mailing list
I haven't imported Smalltalk in to my own namespaces in years now. I often import Core, Graphics, sometimes Net but never Smalltalk. I recommend others do the same, so that they find out what they really do and do not depend on. I like your script.
On 24 January 2014 03:22, Reinout Heeck <[hidden email]> wrote:
The more I write Smalltalk in VW the more I'm bothered with my domain vocabulary being 'taken' by the Smalltalk namespace.
vwnc mailing list
|Free forum by Nabble||Edit this page|