Meaningless Drivel is fun!*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Java - Pure OO? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Java - Pure OO?" Watch "Java - Pure OO?" New topic
Author

Java - Pure OO?

Hassan Naqvi
Ranch Hand

Joined: May 03, 2001
Posts: 158
Hi friends,

I have a confusion regarding purity of Java as OO.
Consider a case when we use only static method,which is not object dependend.In this case we doesnot create Object.Then why Java is called pure OO.
Regards,
Hassan


Always Belive On Logic!!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
A static method is a member of a class object, so whats not OO?
I would not worry about "purity of OO" - you can get into long drawn out arguments with "language lawyers" about this, but they are very unproductive arguments.
Bill
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
You are correct, OO purists argue that static values and methods should not be supported. There are, of course, practical reasons for supporting it, but on principle, no. (That's why most true OO purists are found in academia, and not in software engineering companies. :-)
I don't know who calls java pure OO, but I would disagree with them. (They may mean that's it's more pure than C++, which still carries a lot of non-OO C baggage.)
--Mark
Hassan Naqvi
Ranch Hand

Joined: May 03, 2001
Posts: 158
Hi Bill,
Will you please explain what do you mean by,
"A static method is a member of a class object "
Because as i know any static method is associatd with the class.And not with any particular object.So how could it is a "member of a class object"...?
Regards,
Hassan.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
When the JVM loads a class, it also creates an object which is an instance of the Class class to represent it. This is what allows for reflection. I think that Bill is saying that the static stuff belongs to this class. (??)
Java is also not a pure OO language because it has primitives, some String optimizations and some array optimizations. If it were TRUELY a pure OO language everything would be an object.
[This message has been edited by Cindy Glass (edited June 28, 2001).]


"JavaRanch, where the deer and the Certified play" - David O'Meara
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Oh yeah, primitives, I knew there was something else I forgot. :-)
--Mark
John Dale
Ranch Hand

Joined: Feb 22, 2001
Posts: 399
Can you give an example of the String and array optimizations to which you refer as non OO features?
automatic intern()ing of string literals?
Not that I care about OO purity, but there may be something else interesting lurking here.
David Roberts
Ranch Hand

Joined: Nov 03, 2000
Posts: 142
I don't believe OO means everything is an object. Even in Object Oriented Analysis there are primitive attributes.
So what about static methods? Well since one of OO's intententions is to allow us to model the real world, the question is, does the real world containt something that a static method might emulate?
I'm willing to bet it does. Some operations in real life, at least to the point we want to capture them, are always the same even in seperate instances of these real world things. Also, some things are static and final right?
Maybe like a post-it. Presuming you want only so much precision each post-it has the same level of stickyness that could possibly be measured by a simple data type like a number... this number becomes static and final.
Basically I'm with William on this, except I like arguing a bit more It's rediculous to think that it matters, or that anyone actually has a useful definition. The fact is, do you have a use for it? Is it necessary? Is is an embelishment?
If it's necessary, helpful, understandable or more or less useful then it doesn't really matter.
I personally have never seen a large application be successful and completely OO, so maybe even if it's not pure OO, that's a good thing.


------------------
David Roberts - SCJP2,MCP


David Roberts - SCJP2,MCP
David Roberts
Ranch Hand

Joined: Nov 03, 2000
Posts: 142
Hassan,
I forgot to mention. I don't mean to come off as harsh toward you. I enjoy these types of discussions, otherwise I wouldn't reply.
------------------
David Roberts - SCJP2,MCP
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Hmm, a purely academic discussion on a subtle point, which we all agree isn't very important in the real world. Those are the best discussions. (Because we get detailed and picky, but no one gets offended :-)

Originally posted by David Roberts:
I don't believe OO means everything is an object. Even in Object Oriented Analysis there are primitive attributes.

Are you sure? Couldn't I get away using Integer and Boolean instead of int and boolean. I would argue the use of primatives in OOA is "because they're there," and that if they weren't, we could, in theory, be ok. (I say in theory, because in practice, yes, they are useful.)

--Mark
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Mark Herschberg:
You are correct, OO purists argue that static values and methods should not be supported. There are, of course, practical reasons for supporting it, but on principle, no. (That's why most true OO purists are found in academia, and not in software engineering companies. :-)

True OO purists would argue that classes are objects and therefore class methods are no problem. The same OO purists would also argue that often class methods are overused and should be handled with care.
Also, I don't know any academic OO purists, but I do know some very practical and succesfull OO guys in the engineering community. Kent Beck and Martin Fowler come to mind, for example.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
shailesh sonavadekar
Ranch Hand

Joined: Oct 12, 2000
Posts: 1874
Java is hybrid language. it is not pure oo language. Smalltalk is pure oo language & now it is Ruby.
Your Friendly Bartender
Shailesh.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
SmallTalk is more OO than Java. SmallTalk does not have primitives, for example.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
David Roberts
Ranch Hand

Joined: Nov 03, 2000
Posts: 142
Mark,
That's a good point. Except an Integer has operations, and attributes don't have operations, plus your talking design/implementation, which is not a concern in analysis.
The Integer class is an an example of the Adapter design pattern in my opinion, while an int is a simple number that can be used in OOA.
I would thing that Craig Larman might be considered a OO Purist? Or maybe he's an OO Realist??? He supports simple attributes as OO.
Maybe you guys are right and purists don't think it's true OO, if that's the case call me a Realist...

------------------
David Roberts - SCJP2,MCP
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Hi Ranchers,
After reading ur opines can i come to the conclusion that ----

A solution that is object-oriented is modularized to objects and it may be pure OO solution if we don't have any non-object attributes in it's environment.

Correct me in the manner(or point of view) i m dealing it with...
------------------
Muhammad Ashikuzzaman (Fahim)
Sun Certified Programmer for the Java� 2 Platform
--When you learn something, learn it by heart!


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
What makes something 'pure' OO? I think that it's safe to say that the only 'pure' OO is written in diagrams and pseudo-code. Every language 'suffers' from the fact that it is actually used to do work, not to represent the doing of work. Psuedo-code (or perhaps an infinately complex language) is the only way to perfectly represent what you want, without falling into the traps of actually doing it. It is infinately extensible. No other language comes close.
Srinivasa Chakravarthy
Greenhorn

Joined: Apr 16, 2001
Posts: 1
Even in real world we need to have static members in Class. These Static members are to represent Unique objects like Earth. Any information related to Earth will be common to all objects on Earth. Please comment why an Class if containing Static mambers cannot be called as pure OO.
------------------
Ravi Veera
Ranch Hand

Joined: Jun 23, 2001
Posts: 127
I agree with William Brogden that pure OO is simply an academic concept. It is a goal that would be nice to acheive. Engineers use tools to deliver a product. OO is a tool i.e only a means to an end and not an end in itself.
A few years ago in my incarnation as a VB programmer I used to get mocked at because it was not a 'pure' OO language(Many don't even consider it to be a language). I don't think it was even relavent because it gave me high levels of productivity and even though I have moved on to Java I hold high respect for VB.
Another point I would like to mention about OO is performance. Given the cost of hardware today it is easy to build OO systems and throw hardware to increase performance, but that still does not justify using Integer class instead of int for the sake of maintaining OO purity.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

I throw in with those who ask what makes object purity a virtue to begin with.
In my own understanding, there's a little more emphasis on the word 'oriented,' or 'inclined,' or 'biased.' I like taking objects to the degree they are useful and practical, and then dumping them off when more work is required to adhere to object thinking than other forms.
Objects to me are a strict reaction against monolithic systems built entirely from data structures and applied algorithms conceived in separate camps. A moderate tour through Unix kernel source should persuade anyone that data + algorithms + increasing size + expanding time = headaches.
Objects don't solve that problem, but do make it lots easier to divide and conquer large codebases. It's more difficult to execute well, too. I've always found that bad design in OO looks ugly a lot sooner than it does in C, and that's an advantage of sorts. It's not a dream, but it beats shrugging off rewrites because too much work has already been done.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Cleland Early
Ranch Hand

Joined: Apr 16, 2001
Posts: 38
Interesting discussion. I've programmed in a lot of languages--Object Lisp, Object Pascal and C++ among them. I've also worked with what I would call pseudo oo languages. For example, LotusScript is the scripting language built into Lotus Notes (god awful language, I might add). LotusScript has objects, but no inheritance. That is, I think, a crucial distinction.
My personal opinion is that Java is the most object-oriented language with which I've done significant work. Most of the language is built with objects and many of the things you used have to implement yourself in some sort of class library are provided.
It's been many years since I dabbled in Smalltalk; at the time, I thought Smalltalk was theoretically interesting, but not a terribly practical environment. Even though I spent about 15 months working in Object Lisp, I felt the same way about that language.
I think it's a pleasure to work in Java, so issues of purity don't strike me as terribly important. I find environments where you "program" by typing code snippets in dialogs or by checking checkboxes or radio buttons far more offensive than oo languages that have both objects and primitives.
Cleland Early
Ranch Hand

Joined: Apr 16, 2001
Posts: 38
Interesting discussion. I've programmed in a lot of languages--Object Lisp, Object Pascal and C++ among them. I've also worked with what I would call pseudo oo languages. For example, LotusScript is the scripting language built into Lotus Notes (god awful language, I might add). LotusScript has objects, but no inheritance. That is, I think, a crucial distinction.
My personal opinion is that Java is the most object-oriented language with which I've done significant work. Most of the language is built with objects and many of the things you used have to implement yourself in some sort of class library are provided.
It's been many years since I dabbled in Smalltalk; at the time, I thought Smalltalk was theoretically interesting, but not a terribly practical environment. Even though I spent about 15 months working in Object Lisp, I felt the same way about that language.
I think it's a pleasure to work in Java, so issues of purity don't strike me as terribly important. I find environments where you "program" by typing code snippets in dialogs or by checking checkboxes or radio buttons far more offensive than oo languages that have both objects and primitives.
Scott Cochrane
Greenhorn

Joined: Oct 01, 2001
Posts: 5
I haven't read the whole thread here but I thought I would put in my pennies worth. As I understand it:
Java is not pure-OO. The main justification for this statement is that DataTypes are supported which are not objects.
I believe the most commercially used pure-OO language is SmallTalk. Everything is an object in this language - there are no DataTypes. SmallTalk very obviously sees Classes as objects so you get class methods and variables. A Constructor is a class method. Java sort of hides the fact that classes are still dealt with as objects.
Even when doing "2+3" in SmallTalk this is a special implementation of the messaging sending such that + is sent to the 2 object and the 3 object is sent as a parameter. So although you can write "2+3" in SmallTalk it is still using objects and the messaging sending mechanism.
As people have already said though - it is not a subject worth dewelling on - unless you think you can re-write a language that is better than Java. Java seems to incorporate the best of most languages and is so close to pure-OO it hardly seems worth bothering about - IMHO.
scott


cheers,<br /> <br /> Scott
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
It's these discussions, nay, religious wars, that are the most fun. (So long as everyone is respectful of other's opinions, as people in this thread, and JavaRanch in general, tend to be.)
Originally posted by Cleland Early:
I think it's a pleasure to work in Java, so issues of purity don't strike me as terribly important. I find environments where you "program" by typing code snippets in dialogs or by checking checkboxes or radio buttons far more offensive than oo languages that have both objects and primitives.


Interesting comment. Have you ever used the VisualAge IDE? It is just that; you type code snippets. I assume by the above you were referring to VB or some such language, which is advanced enough that non-programmers can "program" in it without having to write long pieces of code.
The VisualAge philosophy is a "logical extension" of OO, specifically data hiding. You must select an individual method (or class), and then type into that method (or class vairbales and main, if you selected the class). You can't jump between methods just by scrolling up and down in an editing box. This makes sense because the internals of some other method shouldn't effet what you write in the method you're working on. Although the idea is reasonable, I find it very annoying to actually use, since I don't think so abstractly, and do often jump between methods frequently when programming.

--Mark
Cleland Early
Ranch Hand

Joined: Apr 16, 2001
Posts: 38
I'm basically a Mac guy, except for one hellish year I spent working on a Windows port of a Mac commercial application, so I don't have any experience with Visual Basic or Visual Age. I have worked in Lotus Notes, which has several different ways to create applications. You can program in a macro language, which involves typing stuff in dialogs, or you can use LotusScript, which is a Visual-basic-like language (so says Lotus). LotusScript is more to my liking because there's a source-level debugger that allows you to step through the code and examine variables and watch program logic.
The problem I have with using the macro language is that I think it's hard to figure out where things are happening when stuff is broken. I think that when you are isolated from the code that is being written, you will never really understand how it all fits together; therefore, fixing bugs is more difficult than it would otherwise be. The ability to think on a macro level is important when you are writing software, and I think using a visual environment hinders rather than helps you.
Then there are control issues. Who can be certain that the programmer who wrote the code-generating tool knows the best way to program a certain task?
I have similar problems with interface builder applications that write code based on stuff you draw on screen or drag from a dock. I write a lot of HTML, and I've totally given up on WYSIWYG editors. I use a text editor (BBEdit), and I really know how to write HTML. This is very handy when you are writing a JSP or PHP script that generates a web page or trying to find an error in a page that doesn't display correctly.
 
Consider Paul's rocket mass heater.
 
subject: Java - Pure OO?
 
Similar Threads
Hi, All i have a small doubt
JAVA is a pure OO language?
about java oops
is java 100% object oriented
What's This compile error?