If the only tool you have is Java, everything looks like a class
<rant>
There’s a common phrase used within software development:
If the only tool you have is a hammer, everything looks like a nail
It exists in various forms, but the original source is the Law of the instrument, or Maslow’s Hammer.
I started thinking about this while reading through Head First Design Patterns today (a bizarre book, not quite sure yet whether I can recommend it).
What struck me was that the solution to every design problem in Java revolves around writing a new class. It just astounds me that there’s basically no other means of abstraction in the language. I’ve got so used to languages with lambdas, for example, that the idea of creating a LightOnCommand class that implements the Command interface to encapsulate the act of turning a light on feels like such a waste of brainpower, bytes, and sanity. I’d hate to have my expressivity limited so heavily.
</rant>
Reminds me of Steve Yegge’s rant: http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html
@Peter Alexander Thanks a lot! I love a bit of Stevey :)
Unortunately, Stevey forgets that lambdas are also nouns
Because principles of Java revolve about encapsulation of similar functionality within entities that are allowed to have some internal state. Not about having concepts from different paradigms because that would be easier to write.
On the other hand, if you were brought up in a pattern circle, you’d now state that most of the lambdas are a shorthand to implementing Strategy pattern (yeah, I know this is an understatement when a function is a first-class entity). ;)