posted 22 years ago
Well this is more a matter of definition, I feel, than anything else, though it's a definition I'm comfortable with. Java is not 100% OO because it allows primitive types. It's important when discussing this to dispassionately treat this sort of statement as a simple statement of fact and assume it places any value judgment on the language...it doesn't mean Java's good or bad, just that it doesn't follow the 100% OO model, that's all.
In my mind, speaking purely about semantics, these kinds of characterizations of languages can be placed on a spectrum from the OO side to the procedural-oriented side. C falls way on the POP side, C++ in the middle, and Java about 3/4ths of the way to the OOP side. Does SmallTalk peg the OOP-extreme side? I don't think so--as long as there are keywords in the language, those keywords don't represent themselves as objects to the compiler and runtime system, but they sure do represent something, so it's not totally OOP either (from a purely semantic standpoint). If we take the most extreme view of OOP and POP in order to make sure our spectrum has a spot for every conceivable language theoretically constructable, you arrive at the notion that a truly 100% OO language would have to be completely written indirectly through a meta-language that did allow every element of the language itself to remain "pure object". In this way the manifestations for controlling branching and such structures would be objects themselves and totally extensible, blah blah blah.
Not very useful, though. Again, I think it's important to avoid the semantic discussion of "is this x% OO?" and instead just stick to assessing OO through comparison. You avoid semantics that way and stick to the issues that contribute to a langauage's OO-ness or detract. If I say, "Is Java's treatment of Strings OO?" we could get into a long, drawn-out discussion with many valid viewpoints. But if I ask a slightly different question, "Is Java's treatment of Strings more or less OO than C++'s? SmallTalk's?" now we can have a useful discussion that contributes to understanding of what it means for a language to be "OO".
Oh, on the same topic, I thought I'd point this out...I feel that the JavaBeans spec makes a huge error in the quest for OO-ness by defining setters as a core piece of a JavaBean. A setter, to me, is nothing more than just another operation on a class, and I have no compunctions whatsoever about including set operations for variables in other contexts. Getters are pure, in my mind, and more than that, they do deserve special conventions that set them apart from other methods (the getXxx() naming) because you can (ideally) define all of a class' behaviors in terms of its getters.
But consider this case...let's say you are writing a class that has two internal bits of data, and they only make sense if they are both set, or neither. For example, an UserInfo class that has both a username and password. Any attempt to set one without the other, for this application, should result in an exception being thrown, let's say. If you follow the normal JavaBeans getters and setters, how do you write this? You can't write a setter for each property, username and password, because that allows the caller to set one and not the other. In fact, it's required to let the user set one and not the other, at least for a moment...otherwise, how does the user ever set both?
Where do you write the code that ensures one is not set without the other being set to a non-null value? Can't be done inside the class itself following JavaBeans. Now consider the other way:
This is why I think the special recognition given to setters by JavaBeans is not really an advance in helping along the OO usage of Java.
sev
[ February 25, 2004: Message edited by: sever oon ]
[ February 25, 2004: Message edited by: sever oon ]
[ February 25, 2004: Message edited by: sever oon ]