DependentsArray size how does it work ?
denker at iam.unibe.ch
Wed Feb 8 13:32:26 UTC 2006
On 08.02.2006, at 13:58, nicolas cellier wrote:
> I did not understand how first implementation did work, but i
> programmer's intention.
> I used this example to propose a clean understandable collection
> ^self count: [:e | e notNil]
> What you're proposing above sounds a little bit like:
> ^self count: [:e | true]
But of what help is that here? You would need to explain this, too.
> Apart writing the block argument, all code above is correct, tricky
> At least, there is a programmer that can be proud driving me nuts!
You will find *a lot* of code of that quality in Squeak... part of
because Smalltalk is older than the style of programming that was
after people used it for some decades... and because there were other
on the Alto than on today's machines (memory, performance, code size...)
And then there is a lot of stuff that's just bad design... e.g. done
in a hurry because
you don't win with style points when you need to do finish a demo for
The real question is, in general, how to re-engineer, improve and
evolve such a
systems without breaking it, and especially without breaking the
clients that use it.
> Tricky code deserve either refactoring or implementation notes i
> I will try it this evening. if not redefined, then the whole class
> dangerous to me and there might be other side effects.
It gets interesting when you look at the real users of DependArray. The
only place is
self size = 0 ifTrue:[^DependentsArray with: newElement].
^self copyWith: newElement
not directly obvious way of doing it, either: lazy convertion of empty
arrays, with the place where the real instanciation should have
More information about the Squeak-dev