moosetechnology / Famix

An abstract representation of source code. Famix is generic and can describe applications in multiple programming languages.
MIT License
13 stars 23 forks source link

MooseGroup and Collection API tries to be too clever #722

Closed NicolasAnquetil closed 6 months ago

NicolasAnquetil commented 8 months ago

MooseGroup tries to be clever to handle the complete API of Collection

This is done by implementing #doesNotUnderstand: and redirecting the message to the internal collection of MooseGroup (and if this redirection does not work again, then it re-sends the original error)

First I generally think that capturing doesNotUnderstand as "normal behaviour" is not a good idea. I would prefer that we implement by hand all the methods that we need. It is not difficult, each time something is missing we add the method and delegates it to the inner collection ...

Second, the current #doesNotUnderstand: implementation is buggy, it tries the message on the inner collection and if this raises DNU again, it signal's it without looking what is not understood. We had a problem here, were #select:thenDo: was sent to a MooseGroup. It was not understood and #doesNotUnderstand: resent it to the inner collection. And this worked. But then inside the block somewhere down the road, another DBU was raised. And it was captured and signaled as 'MooseGroup does not understand select:thenDo:' which was completely misleading (the actual problem was that some other method was send to nil).