

Monkey-Patching, Single Responsibility Principle, and Scala Implicits - danielharan
http://jamesgolick.com/2010/2/8/monkey-patching-single-responsibility-principle-and-scala-implicits.html

======
lincolnq
Implicit type conversion is often noted as a misfeature of C++ and PHP. I've
never used them in Scala myself, but they are highlighted as a positive
feature of Scala in this article, and I am inclined to believe the author when
he says they are.

The insight here was just that implicit type conversion is very bad when you
don't know it's happening. When you DO know it's happening -- because you
imported the conversions -- and it's used to save brainstrokes ("codetree
nodes"), then it can be very helpful.

------
jamesbritt
"The technique is known as monkey-patching. "

There seem to be two views of this among Rubyists. People who think this sort
of practice is inherently suspect, and those who see it as no more unusual
than reassigning to a variable.

The first group use the term "monkey patching"; with all of its underlying
tone of ad-hoc-ery and last-resort duct tape coding.

The other group just refers to it as re-opening classes.

------
bruceboughton
In C# this is called extension methods: monkey-patching (for methods) without
polluting the global scope.

------
wheaties
Like all powerful things, when used properly implicits add rather than detract
from the code. In Scala's case, you can limit the scope of the implications
which is just so nice. I'm not a fan-boy but it sure beats the heck out of
Java.

------
kevinpet
The advantage of implicit conversions over monkey patching seems solid, but
I'm not an unqualified fan of implicit conversions either. As a Scala newcomer
(i.e. never written a significant app in Scala myself), I find implicit
conversions hinder reading code closely enough to be able to modify or extend
it. Although the original author may know which import has added some implicit
conversions, why, and what they do, this isn't easy to discover after the
fact.

It seems that the Idea plugin will show the implicit conversions that are
actually used, but it would also be nice to see all implicits in scope at any
time.

