Quote:Original post by voguemaster
Quote:Original post by ApochPiQ
That mentality is that all operations should be done by objects, which is what most people mean by the term "object oriented." That mentality is unhealthy and leads down the Dark Path to languages like Java.
There is nothing wrong with Java. In many ways, Java is much better for development and debugging.
If you're talking about raw performance, as always that depends on the task at hand. Generalizing by saying that Java is slower than C++ is only technically true, not in reality.
When saying that Java takes away control from the programmer, that too is true but for 80% of the programmers, that's probably a good thing.
No dark path and no nothing. It all depends on your requirements.
That quote cannot be taken out of context without losing all of its significance.
Java's a great platform. The Java language is marginal. Java's obsession with objects is disgusting and causes code to be significantly more verbose than is really needed.
Writing "object oriented" code in
any language tends to create designs that resemble Java programs, where every single piece of logic is contained in an "object" (i.e. class), even when that makes absolutely no sense. It is almost always possible to take an "OO" design, strip out objects where they are not strictly needed and write functional-style (or even procedural-style) code instead, and end up with a net improvement - code will tend to be more concise, more efficient, and better abstracted.
The typical "good OO design" is to build parallel vertical columns of abstraction, with small sets of objects working with each other and being "related" to a narrow hierarchy via inheritance. This model is fine in vacuum, but as soon as these objects have to start interacting, the typical solution is to build a lot of "helper objects" that take care of the interaction.
A far better way to build abstractions is in horizontal stratified layers. You basically build a mini-language; all logic should be expressed in high-level terms. Large projects may have several layers of such dialects. This produces code that is more reusable, more concise, easier to understand abstractly, and far more tolerant of small changes to specifications and requirements. (Watch the
SICP video lectures for a good treatment of this.)
Using objects to model everything in a system leads to code that is needlessly verbose, buggy, prone to abstraction leakage, and intolerant of requirements changes. A classic symptom is the supposed "need" for things like Singletons and Monostates in the first place. The "canonical" Singleton, a logger, makes vanishingly little sense as an object the way most loggers are implemented. A namespace of functions would be far more appropriate.
Even Monostates are, in general, a poor attempt to disguise sets of functions as objects.
Some things just are not objects, and shouldn't be modelled as such. That's the point of my journal post, and the meaning of my reference to Java earlier.