Software Developer

Smalltalk, Swift, Java, Obj-C

@fstephany | Email | LinkedIn

I'm currently working at Ta Mère SCRL a small development shop in Belgium.

We mainly do mobile apps (iOS, Android) for clients. We also have a strong interest in Pharo Smalltalk and Rust.

logo Ta Mère SCRL

Limit hard dependencies in your code

17 May 2012 in advice code smalltalk 

Igor Stasenko summarizes what he does to avoid coding with hard dependencies in his code:

Rule #1. never make more than 1 reference to any class external to your package in your code. an exception is kernel classes.

which means, that you are allowed to do Set new or Array new, in any place of your code but never SomeFooClass new more than once.

If your code having such dependency, localize it in single method:

  ^ FooClass

and then use self fooClass everywhere.. Like that, if you will figure out one day, that sand moves under your feets, you’ll have to change only single method. :)

I never felt the need of doing that when the refactoring browser can rename all that for you but it’s still make sense if you want cleaner code.

Thanks Igor :)