[squeak-dev] Coding style (was: Future of Squeak, and outsider's view)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Coding style (was: Future of Squeak, and outsider's view)

Michael van der Gulik-2


On Tue, Jun 30, 2009 at 4:53 PM, Cameron Sanders <[hidden email]> wrote:

On Jun 30, 2009, at 12:22 AM, Michael van der Gulik wrote:

Back to the question of adding behavior to classes that you don't own. VisualWorks has a means to extend a class in a different package ... as I recall. As I recall, squeak has no such capability, right?


Squeak certainly has that capability, but I would discourage you from using it.

Why?


It's a gut feeling thing rather than any serious good coding practise.

Often if you feel the need to put code for your package in another package, then that other package was somehow deficient and your modifications should be made to that other package "properly".

If your package modified another package such that it gains knowledge of other class's internal behaviour, you're breaking encapsulation and leaving your code prone to breakage when that other package changes.

Collisions can occur if two packages try to modify the same method on a third package.

It spreads your code around. I like to keep my code in one place and I've personally got a tendency to write slightly less elegant code which is "right here" in preference to modifying external classes.

Gulik.

--
http://gulik.pbwiki.com/