[squeak-dev] StandardToolSet class>>inspectorClassOf:

Eliot Miranda eliot.miranda at gmail.com
Mon Feb 5 18:43:24 UTC 2018


Hi All,

    I find this method broken and sad:

inspectorClassOf: anObject
"Answer the inspector class for the given object. The tool set must know
which inspector type to use for which object - the object cannot possibly
know what kind of inspectors the toolset provides."
| map |
map := Dictionary new.
#(
(CompiledMethod CompiledMethodInspector)
(CompositeEvent OrderedCollectionInspector)
(Dictionary DictionaryInspector)
(ExternalStructure ExternalStructureInspector)
(FloatArray OrderedCollectionInspector)
(OrderedCollection OrderedCollectionInspector)
(Set SetInspector)
(WeakSet WeakSetInspector)
) do:[:spec|
map at: spec first put: spec last.
].
anObject class withAllSuperclassesDo:[:cls|
map at: cls name ifPresent:[:inspectorName| ^Smalltalk classNamed:
inspectorName].
].
^Inspector

Is this really to be preferred over sending inspectorClass to the object?
This method is bad because it is a point of collision for anyone who wants
to add a custom inspector.  Hence it creates unnecessary conflicts between
packages, whereas implementing inspectorClass allows one to keep things
separated.

The late binding/defaulting the use of the class name and classNamed:
provides here could be achieved by implementing Object>>inspectorClassName
just as easily as this hard-wired table.

_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20180205/0175fb49/attachment.html>


More information about the Squeak-dev mailing list