Re: OO is not that great: many repeated codes



topmind a écrit :
sjdevnull@xxxxxxxxx wrote:

topmind wrote:

Java is hardly a good role model here. Forcing everything to be a member of
a class is not the same thing as enabling elegant code.

It appears that you are agreeing with the original claim that sometimes
procedural is less code than OO. Java is "bad" because it forces every
function to be a member of a class (or object)

Objects and classes are different things.


It depends on the language and which definition of OO one is using.
Dynamic languages tend to make less distinction between classes and
objects. A "dynamic class"

What's that ?

usually looks so much like an object that
one might as well make them an object to simplify the language rather
than support two almost-the-same things.

In Python, classes are objects, and it's not a unique case AFAIK.


And yes, to many OO programmers Java is "bad" (or at least sub-optimal)
because it encourages everything to be part of a class; to a Smalltalk
or Python programmer, forcing everything to be in a class is very far
from what OO is about. There is a very large segment of "pure OO"
advocates who aren't big fans of the C++/Java-style class-oriented
verbosity.


A global function may not qualify as an object/class though.

Why not ?

Sure, one
can shoehorn it into an object, but anything can be shoehorned with
enough pressure and screaming and/or fancy syntax shortcuts, such as
"default methods".

def someFunc(arg):
print arg

isinstance(someFunc, object)
=> True

Where are the pressure, the screamings and the fancy syntax shortcuts ? Unless you count the fact that the def statement yields a function object as "fancy syntax shortcut" ? If so, I don't see any problem with it...
.