Scala and interfaces

Scala has traits, which are interfaces on crack. Really, they’re what interfaces should have been, admittedly, there are limitations when it comes to constructors, but that’s not really a big deal considering the fact that if you have two interfaces both having requirements of the constructor you’d run into the same issues.

Then there are partial methods, and in a lot of ways many of the good object oriented design principles based around dependency management could almost be seen as ways of getting units of work that are more composable, you really have to wonder. Instead of only being able to work on method inputs and outputs, or predefined points where a strategy object/method is employed you have a bit more flexibility.

Add to that companion objects and all of a sudden factories and a whole lot more become far more trivial.

Given that’s the case, you really can get away from having to use interfaces everywhere, and with more powerful generics system, some of what gets done with interfaces gets sucked up there.

Generally looking at Scala code it tends to be rather decomposed, and interfaces don’t seem to be the main tool in that.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)