Talk:Object-oriented programming
This is the talk page for discussing improvements to the Object-oriented programming article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
Archives: 1, 2, 3 |
Computing: CompSci B‑class | ||||||||||||||||||||
|
"Decoupling"
The term "decoupling" is vague, and has a buzzword feel to it. Attempts to objectively measure it have been problematic or depends on many unproven assumptions. I'd suggest not mentioning it. --66.120.226.84 (talk) 18:30, 24 October 2008 (UTC)
- I don't think the term is vague at all, though I think the article currently does a terrible job of explaining what it is (namely, elimination of inter-object dependencies by use of encapsulation/information hiding/interface rigor). Nevertheless, neither "decoupling" nor "instance" is among the "quarks" listed in Armstrong's original (2003) paper submitted for publication, which is available free online at [[1]] (retrieved as reference number ITRI-WP034-0303). The version published in 2006 is available from the ACM at [[2]], but you have to be a member (I'm not). Unless the published version added "instance" and "decoupling", they should be deleted from the article. -- Unconventional (talk) 19:10, 14 November 2008 (UTC)
- I suggest either finding a good clean formal definition along with a wiki article, or not mention at all. Doing it half-way is confusing to the reader, who will already be burdened with lingo. --63.192.29.10 (talk) 16:01, 10 May 2010 (UTC)
"Design Patterns"
Should we be listing the 23 patterns here, given that there's a Dedicated Wikipedia article on the book? Gerardw (talk) 12:22, 19 December 2008 (UTC)
"Misleading sentence"
"In the 1980s, there were a few attempts to design processor architectures which included hardware support for objects in memory but these were not successful. Examples include the Intel iAPX 432 and the Linn Smart Rekursiv."
"Not successful" is misleading here, the fact that the iAPX 432 was slow or Rekursiv not successful commercially doesn't mean that they not were succeseful implemting OO in the MMU. —Preceding unsigned comment added by 200.127.136.93 (talk) 02:17, 6 January 2009 (UTC)
Section "criticism" needs expansion
Would very much like to see the section "criticism" expanded to at least a couple of paragraphs. I am not at all competent to this myself. -- 201.37.230.43 (talk) 14:09, 21 February 2009 (UTC)
- I agree with you that it needs expansion. Instead of destructive criticisms, rants or laconical criticisms that do not help the reader to assess the benefits and limitations of OO technology, what I would like in that section is published, referenced examples of specific, well-delimited problems where a "pure" OO solution would be inherently more complex, harder to understand or harder to evolve than a solution to the same specific problem using another technology (say, DSLs, functional programming or even cell-oriented programming like in Microsoft Excel).
- Now this would be a nice contribution to improve the article so that it provides a better overview of the characteristics, advantages and limitations of OOP. --Antonielly (talk) 16:56, 21 February 2009 (UTC)
The current criticism section reads in a petty and personal way. It doesn't read like an encyclopedia should at all. --M2tM (talk) —Preceding unsigned comment added by 207.47.201.6 (talk) 00:51, 4 August 2009 (UTC)
- It seems to me that anyone who dares to criticise OOP (or wonder what all the fuss is about), is seen as unknowledgable/reactionary/ petty or similar. If you actually care to look at the experience and stature of these critics you will see that this is not the case. As a programmer myself, with more than 40 years experience (and many successful products), I actually believe that conventional programming is far more efficient, faster and does not involve largely undefinable terminology and "get arounds"/"fudges". It is suspicious, to say the least, that nobody has yet provided a recognizable generic definition of OOP or provided proven benefits. I have spoken with several well respected programmers who, like me, have yet to accept any of the so-called "benefits" of OOP. Sadly it's another example of "The Emperor's New Clothes" that has simply got out of hand in a massive way.
- In the same way that you normalize relational databases you can normalize objects to move their state closer and closer to the behavior that utilizes it. This is the benefit of true object oriented programming when used correctly. You get logical containers or 'tools' that are specfic behaviors married to their state. This allows stability through immutability. Other programmers using these stateful/encapsulated objects can trust that they will behave the same no matter who else is utilizing that object within the program. In contrast procedural or data driven programming like i've often seen used in VB6 or COBOL programs the driver program maintains the state and governs over mutability and the classes merely have behavior. You pass state into the behavior and you you get back a modified state or you get back a result or condition of whether or not your behavior succeeded. All of which your driver program must maintain. The benefit of procedural program is one of 'visibility' into state management and less 'delegation' as you can read the driver program as one document of events happening. My only citation is my experience of 13 years in software development. The enlightened software developer knows when to employ OOP or procedural or SOA or any new paradigm as it comes about. Only zealots use one and speak against the others.
- "It is suspicious, to say the least, that nobody has yet provided a recognizable generic definition of OOP or provided proven benefits."
- The same can be said about cults. Are you equally suspicious about the effectiveness of cults? Kidding aside, this is called a continuum, in the real world(OOD), continuum exist.
Section "criticism" needs contraction
As of 2010, I think we have a little perspective about what criticisms of OOP proved to be valid or at least insightful, keep those and drop the rest. Otherwise what we have here is a List of failed predictions regarding object-oriented programming patsw (talk) 18:04, 20 July 2010 (UTC)
well, I use oop a lot, I find it a very useful technique. But I also am aware that it has a fad like nature, in the sense that it has been very much over hyped (cough cough ruby). I find the anti-opp quotes to be refreshing, illuminating, and humorous. It makes for a great counter-balance to a subject that is often lopsided. My vote is to keep the quotes. I'm a programmer who been at it for about 30 years. 67.40.8.215 (talk) 07:40, 9 December 2010 (UTC)
"Static programming languages"?
The criticism section implies that OO is a feature of "static programming languages" as opposed to Lisp.
- Object orientism requires no specific language feature other than the ability to encapsulate or 'black box' state within a container and expose behavior to external containers.
- I can't find the term "static programming language" in the literature. Is this phrase supposed to refer to "statically-typed programming languages" (e.g. C++), as opposed to "dynamically-typed programming languages" (e.g. Lisp)?
- If so, why is OOP exclusively associated with statically-typed languages, when there are so many OO or multiparadigm dynamically-typed languages (e.g. Objective C, Python, Ruby, etc.)?
I am not knowledgeable enough about Lisp (or OO design, for that matter) to rewrite this section. Could someone clarify, or at least add some references? --Otterfan (talk) 23:36, 16 March 2009 (UTC)
Wait, I get it--"static programming languages" isn't a commonly-used term, but it appears that "dynamic programming languages" is. Still, there seem to be a lot of object oriented dynamic programming languages. This still needs clarification, or at least some references. --68.239.60.5 (talk) 04:11, 19 March 2009 (UTC)
- I'm no expert on langauge definitions, but I understood the term 'static language' to be as above - ie not a dynamic language (such as lisp) (aside comment eg maybe compiling to a contiguous machine code without any list structure connecting 'bytecode' as might be found in a dynamic language)
- I definately didn't think it refered to static/dynamic typing.
- If that's the issue maybe a note type reference would be a good idea - clarifying what is meant by 'static programming language' ?
- Or was the issue whether or not the statement(s) is(are) true?83.100.250.79 (talk) 22:38, 26 June 2009 (UTC)
Object vs Instance
These are the exact same thing. That should be explicit. —Preceding unsigned comment added by 81.252.207.82 (talk) 13:43, 20 March 2009 (UTC)
- No. This is the same only in the language that support classes. P99am (talk) 11:57, 24 April 2009 (UTC)
Fundamental concepts
Fundamental concept of Object Oriented paradigm is object, not a class. Define objects as the implementation/exemplar/instance of a class is not correct. This is a purely technical definition in some languages (supporting classes). Object Oriented Programming is not equals Class Oriented Programming.
Section Fundamental concepts turns everything upside down.--P99am (talk) 11:57, 24 April 2009 (UTC)
Physical existence of an "object" - is it unecessary baggage? - can occams razor help?
Try as I might, I have not yet come across any instance (definition) of what an object is - in physical terms. I understand that OOP defines objects in some physical sense (rather than a virtual data definition) but I have yet to come across an actual example of how this manifests itself internally in the OOP language. I think I have seen these objects in an 'exported' sense - with seemingly long strings of (comma separated?) text attributes - but what of its internal representation? For example -
- how large is a (typical) object definition (in bytes)?,
- does it have an inherent or implied structure or OOP standard? (and is this portable?),
- who decides what attributes it holds and in what (optimized?) form?,
- how much data is involved when accessing an object?
- how much processing is involved in decoding the object at execution time?
Since conventional programs can (and do) perform the same tasks as any OOP written program - without the need for any physical objects - this seems to imply that the physical objects themselves are a case of unecessary 'baggage' (requiring additional processing themselves). Using occams razor therefore, these pieces of baggage can therefore be safely removed and a more optimum solution used to provide algorithmic efficiency. This optimum solution, I would suggest, is the much simplified "conventional" programming paradigm that grew up around the first computers - unsurprisingly - as the most 'natural' way to program them.
If someone has a real life example of how an object manifests itself physically (in a particular language) perhaps they would be good enough to highlight a simple example of it here for everyone to compare with a conventional solution. It would be useful to answer the questions above in relation to their example also. If the example is good enough to serve as a generic illustration, of an OOP object perhaps they might also include it into the article itself to educate all of us? It would also be nice if the example refrained from the much overused animal metaphores and restricted itself to more real-life scenarios such as simple addition of two values (unless of course you think I am 'barking up the wrong tree' or just simply barking!) ken (talk) 11:11, 21 August 2009 (UTC) Two weeks have passed since my post above. No sign yet of a response! Isn't there anyone who can defend the OOP 'paradigm' with a concrete example of what constitutes an object in reality (at least in one language) and then go on to explain the mechanics of how this is superior to a more conventional imperative programming approach using a real life example. Since I posted the above, the thought occurs to me that such a physical object must, of necessity, be an object itself - leading to a "vicious" infinite regression of objects, each describing themselves. See also my comments in Talk: Object(computer science) Can we implement OO in any language?!!ken (talk) 09:33, 5 September 2009 (UTC).
- Nobody replied because it's not worth replying to. See the banner at the top of this talk page? This discussion page is meant strictly to improve this article. Wikipedia is not a forum for debating hot topics. Do you have some concrete improvement to propose? Pcap ping 10:57, 5 September 2009 (UTC)
I would have thought that an example of what an 'object' is, is quite central to the concept of object-oriented programming. If nobody can provide one it is, to say the least, quite peculiar. Presumably if you are so confident that there is no improvement that can be made to the article, you can either provide a link to what I am asking for on some other published site or can point to the place in the existing article that answers my question.ken (talk) 15:05, 6 September 2009 (UTC)
- Where does this article discuss the "physical existence" that you debate? I'm unable to find it... Pcap ping 15:52, 6 September 2009 (UTC)
That is precisely the point! The article linked to in the introduction (i.e. object (computer science)) describes the OO concept of "'physically' bringing together the data components with the procedures that manipulate them". In any case, it would be difficult to see how an (OO) object could have any reality without this being the case (essentially being a combined data description and a function pointer). However, how this exactly is implemented is not shown by example - in any language in either article - despite the fact that (OO) objects obviously can be manipulated independently of the underlying 'target' object (the data) and therefore must have some physical existence. —Preceding unsigned comment added by Kdakin (talk • contribs) 19:07, 6 September 2009 (UTC) Two weeks later! On my tedious search for an answer to my question, I came across this java topic [3]which seems to at least confirm my belief that OOP objects do indeed have a physical existence. If they have a length in bytes they surely must contain something! The obvious question, which I am still short of an answer to is, precisely what? It reminds me of the question "How long is a piece of string" - at least I now know it has a length - now please what is the string made of? (and please no flippant answers like green cheese or quantum soup or quarks!) ken (talk) 09:19, 21 September 2009 (UTC)
- Its data members, and a vptr, is one possible answer. But these are implementation details, and not really important to such an abstract topic as this. Regards, decltype (talk) 09:49, 21 September 2009 (UTC)
Sorry Decltype, but I think telling me that there are pointers (rather obviously!) embedded within 'objects' is not the answer I am looking for. I also believed that objects pointed to 'data members' and did not actually contain them. Why do you think this is an 'abstract topic' and not a real one? The whole point of the question is to ask why there appears to be no example of what EXACTLY an object is - when implemented (and incidentally - how much memory and processing overhead this represents). To explain it by saying it is 'abstract' and just an 'implementation detail', is avoiding the very relevant question of precisely that. If you don't actually personally KNOW the answer (from the experience of a compiler writer for instance), why bother to attempt a 'possible' answer?ken (talk) 18:13, 21 September 2009 (UTC)
- That's not so obvious to me. An object need not contain any pointers, and most certainly not a vptr. However, this is one common way of implementing virtual functions (which some would say are vital to OOP), and causes an overhead the size of a pointer. However, as the vtable article (hopefully!) tells you, this is just one possible way of implementing late binding. Now, in most C++ implementations, there will be no overhead except for the vptr (in the presence of virtual functions), and the caveat that even an object of class type with no member subobjects must occupy at least one byte (with one exception). Apart from that, the objects contain their base class(es), and their member subobjects, and not pointers, unless the member subobjects are themselves pointers. However, even the simplest class may (or may not) contain unnamed padding. Most compilers allow you to manually adjust alignment. Thus, the object layout can be completely different even for two executables created from the same source code with the same compiler, and the answer to the question of how much memory overhead there is for each object remains the same: It is entirely up to the implementation. Regards, decltype (talk) 06:25, 22 September 2009 (UTC)
Thank you Decltype, I am now (ever so slowly) getting a beakdown of an 'object'
So, now I know that:-
- objects are at least one byte long (except in one case apparently)
- true, but this is very C++-specific. The exception is the Empty base class optimization. The fact that not even I have bothered to create an article on it yet, indicates that it's not that significant.
- objects may have automatic, or manually specified, padding
- Yes. The article seems to give a good overview, so no additional comments
- objects 'contain' their base class(es), and their member subobjects, (- whatever that implies? ) and not pointers
- Member subobject = data member.
I also strongly suspect (but do not know for sure) that:-
- they have a physical name (in the form of a character string equal to its string length) - not mentioned by you
- No, this would be incredibly wasteful. Type identification can be facilitated for instance by examining the vptr.
- most objects have pointers to at least one method (multiple methods implying multiple pointers)
- Typically, member functions are implemented like normal functions, except that a pointer to the object ("this") is passed as a hidden argument to the function.
- not all methods are virtual functions - fair enough
- This is certainly not true for other languages. In many OO languages (such as Java), methods are "virtual" by default.
- different implementations imply different 'object' structures (- which I would venture is a little inconsistent for an entire new paradigm!)
- the actual implementation of an 'object' is not itself derived using OOP mechanisms for the 'objects' datastructure
I also suspect that:-
- the attributes of an 'object' are held within the object in one form or another - not mentioned by you
- I'm not sure what attributes you are referring to, but a conforming implementation need not put anything but the raw data of the data members (+ base class instances) inside an object.
- 'subobjects' are chained from base classes (and to one another) by some pointer mechanism - not mentioned by you
- No.
- objects require 'creation' and usually 'initialization' before being used - not mentioned by you
- I didn't realize you were asking about this, but sure, see constructor.
I am, in fact, only asking for a breakdown of ONE implementation so that I (and others using wikipedia) can see 'what makes OOP tick' at its basic level. Just one example of the Data structure of a couple of 'objects' (in their entirity) complete with names, init. & method pointers and object attributes would suffice, along with a narrative of how the objects are created, processed (and destroyed?) in a typical scenario like adding two integers together. This does not have to be in hexadecimal, Pseudocode will be good enough to get a rough idea of the sizes of data and processes involved.ken (talk) 07:06, 23 September 2009 (UTC)
- I am going to break the normal conventions of the talk page to address your points individually. Unless otherwise noted, my answer holds true for most common C++ implementations, but may be blatantly wrong for other programming languages. decltype (talk) 07:28, 23 September 2009 (UTC)
The more I learn about OOP, the more I realize that even its protagonists appear not to understand it sufficiently to give a clear and concise definition of what it is. Here [4] is a link to the OOP article in wikibooks that is about as clear as mud. Why is it so difficult to show a simple example of precisely how the memory is mapped for adding two values together? Let me make it easy for someone and put my wish into the form of a question perhaps set at GCE 'O' level.
Q.There are two 32 bit integers in contiguous memory locations A and B. The integers were read in together from some external I/O device as a single record and some general register points to the start of the record as the program is given control. It is required that the program adds the two input values together and passes the resultant value as a return. Draw a diagram to show the necessary memory 'blocks' used by the program and describe each step in the process using pseudocode (show ALL your workings). Do this for a conventional program and an OOP program.
- 6 months later and still nobody has responded to the challenge! Meanwhile I discover myself some more of the hidden awkward truths behind OOP implementations - heap storage used to create new "objects", calls to constructors to initialize them and heap storage used for message passing - containing (largely unecessary) exact copies of parameters; "getters" and "setters" instead of direct assignments; serialization/marshalling - breaking both so called encapsulation and data hiding. Return values provided from sent messages (instead of waiting for a result message in response) - making a mockery of the concept of true message passing. More getarounds than rats in a maze. Proprietory data mappers to automate multiple conversions between object and binary formats. Free format human readable character text strings of data and attributes used to describe data objects externally. Discussions about whether binary XML solves the newly created data compression problem or not. Parsing, parsing and yet more parsing seems to be all the rage these days. The abstraction penalty - written large - is, it seems, most evident in OOP. When will it all end - and sanity once again prevail? —Preceding unsigned comment added by 86.142.16.251 (talk) 11:14, 21 April 2010 (UTC)
okay, I'll byte.. or at least take a nibble at this ;-) You are thinking much too low level and perhaps paradoxically, not low level enough. vptr is a good answer to your original question, you just lack the background to be able to understand the answer, perhaps a better answer would be to tell you that it's "42". The high level understanding is that an object is a private name-space referenced by a public interface. What an object does is that it groups together zero or more data items, and provides standard methods for accessing and modifying that data. The relationship of the data items to each other and to the world is defined by the object itself via zero or more associated program routines (usually) called methods. Everything else is an implementation detail and is totally language specific. The bottom line is that an object encapsulates (containment) things that the programmer has decided are useful to be packaged together. To ask questions about the storage size of an object is to display a complete lack of understanding of computer programming. Which then brings up the question of who is this article written for? If it is intended to be useful to non-programmers than considerably more explanation is needed. But if that were done I suspect the article would be encumbered to such an extent that it was no longer of interest to programmers.... codeslinger_compsalot 67.40.8.215 (talk) 08:39, 9 December 2010 (UTC)
Formal def issues
Here's why I tagged those bullets:
- coalgebraic datatypes -- these are infinite data types like streams; not clear how they apply here. Is this a confusion with System F-related stuff?
- recursion -- seems too simplistic; is this a confusion with open recursion?
Pcap ping 17:44, 26 August 2009 (UTC)
Pointers are routines?
How so? Is this about pointers to functions? If so it needs some rewriting. Pcap ping 19:23, 26 August 2009 (UTC)
OOP with ANSI-C
"ANSI-C is a full-scale object-oriented language" Object-Oriented Programming With ANSI-C by AT Schreiner - 1993
It would be nice to have a section on OOP techniques in non-OOP languages.
Removed external link to a Richard Mansfield article
I have removed an external link to a purported whitepaper by Richard Mansfield titled "Has OOP Failed?". It seems to be little more than a subjective rant; the author refers to computer science as "computer 'science'," claims that most programmers prefer non-object-oriented languages without citing a single source, etc. dpol (talk) 22:31, 14 March 2010 (UTC)
Mr. Mansfield has been in the industry quite a while and has been involved in many publications. This qualifies him as an experienced industry observer. There is not a lot of direct evidence on the benefits of OOP either way such that if you turn up the scrutiny knob, the entire article may end up disappearing. --63.192.29.10 (talk) 16:07, 10 May 2010 (UTC)
Abstraction is also achieved through Composition
Abstraction section says "Abstraction is also achieved through Composition". Could we get a source? All references on internet seem to come from wikipedia.
Section History
Hi, When I was reading about the two commercial products, it struck me that there was only one example given. I think that is not in line with the objectivity of Wikipedia. Moreover, this example - which I do think is a beautiful characteristic of VB.NET framework - can be put into more perspective of the principles of Object Oriented Programming, which is the subject of this article. This cross-language inheritance is an interesting way to abstract code from implementation using the Strategy pattern. Java does have a similar feature, the virtual machines, which is abstracting the code from the implementation as well, but now using the Adapter pattern. So I thought I could enrich the example provided, extend it with another example from the commercial world thereby raising the objectivity of this article using just three sentences. I do hope one approves. Loekbergman (talk) 06:23, 27 July 2010 (UTC)