Talk:Protocol (object-oriented programming)

From Wikipedia, the free encyclopedia

[edit] Disputed sense of protocol

The term protocol in object-oriented programming means more than just the signatures of the methods owned by a given class. The protocols of a class include how that class expects to be used, viz. the order in which methods expect to be invoked. This is now recognised, for example, in UML 2.x statecharts, where the term protocol machine is used to describe the state machine of a class, representing legal sequences of method invocations. This behavioural use of protocol goes back to Smalltalk days (although in some contexts, the weaker sense below was intended).

In the mid-1980s, the programming language Objective C introduced the term protocol as a syntactic term to denote an abstract interface, containing method signatures only, defined independently of the single-inheritance class hierarchy. This usage is more or less synonymous with the syntactic construct interface in Java, and was invented for a similar reason (viz. the desire to support only single inheritance, for convenience of implementation, but still allow multiple classification).

So, I would like to argue that the neutral definition of protocol should refer to the deeper, behavioural sense; and the Objective C usage (which is a specific syntactic term in the language) be moved to a page that discusses object-oriented interfaces in a neutral way, which subsumes interface (Java) and protocol (Objective C); and possibly also concept (C++ standard template library). AJHSimons (talk) 15:51, 18 February 2008 (UTC)

[edit] Merge with interface (Java)

Regarding merging it with Protocol_(object oriented programming)... This article is fine the way it is. I was searching it, and found it in one go without having to dig through protocol --> object oriented --> java --> interfaces. 70.113.115.138 04:46, 20 February 2007 (UTC)

The Interface is a Java term, not necessarily an object oriented programming term. Other languages use other terminology for similar technologies. This entry might reference the OOP protocol entries but should remain separate. Dblatt 13:21, 18 April 2007 (UTC)

I agree with the above opinions. I had no idea what a Java Interface was, nor that it was related to OOP Protocol. I searched for it and found it easily this way.--89.180.27.21 20:15, 3 May 2007 (UTC)

Due to the fact that this article is flagged to be 'wikified', I believe that merging this with Interface (Java) would only serve to degrade the quality of that article. Ph0t0phobic 23:13, 1 June 2007 (UTC)

I am not saying that the Interface (Java) article is bad, but there just is no place for it.
The Java term "interface", which is also adopted by many other OOP languages, is equivalent to "protocol" as defined by this article; indeed, the lead section even lists it as a synonym. Given that the functionality of interfaces in all the Java-derived languages is the same as the one described by this article, there is no reason we should have this article and a separate Java-specific one separately. Having two articles on the exact same topic can only serve to fragment Wikipedia and duplicate effort.
The merge needn't degrade the quality of either article: the whole point of merging is to choose the good and throw away the bad. I am hereby re-introducing the merge tags. -- intgr #%@! 07:39, 28 August 2007 (UTC)

I agree with the opinions to keep this page seperate. The fact that it is a Java specific topic is the ultimate reason why I think it should remain seperate. The Protocol page should remain generalized and should have no specific indication of language dependancy, except for maybe in examples, in which case appropriate comments should be made. Alex 18:41, 28 September 2007 (UTC)

How are interfaces Java-specific? So I suppose we should write interface (C++), interface (C sharp), interface (Object Pascal), etc too? And well interfaces is hardly the only feature of programming languages, why why not array (Java), array (C++), array (Pascal), array (Perl), array (Python) ad nauseam. Because this is exactly what you're proposing here!
Interfaces in Java are not special, the article is just an unnecessary content fork. -- intgr [talk] 12:30, 29 September 2007 (UTC)

[edit] Merge with concepts in C++ STL

No point in having separate articles for each language - one thinks of C# interfaces, and C++ concepts that will become standard in 2009 (see Concept (generic programming) and C++0x#Concept). Well, same thing; this article should explain the general idea and give a couple of examples to illustrate its implementation in each major language (and not to serve as a comprehensive programming guide). That is: Interface (Java) should be pruned a bit and merged from. GregorB 22:14, 3 October 2007 (UTC)
Yes, and everything that's left of Interface (Java) after "pruning a bit and merging from" would be simply a tutorial, and should be deleted anyway (WP:NOT#Wikipedia is not a manual, guidebook, or textbook). That's what a merge is. -- intgr [talk] 21:01, 7 October 2007 (UTC)

Java interfaces are completely related to interfaces in other languages and C++ pure virtual functions and all fall back into the definition given in this article, and should be merged.

That being said, C++ concepts are not quite the same. Concepts in C++ will define a set of requisites for a given metaprogramming template, that is in a different level than Java interfaces, C# interfaces or C++ pure virtual methods. The latter define an specific message, while the former does not require the existence of a message. A C++ concept may define that there is a + operator that applies to class A and class B, but it does not require an A& operator+( const B& ) method in A class definition, the same functionality can be expressed in any other way, like an out of class A operator: A& operator+( A&, const B& ), thus a concept may not require a definition of a message between two classes (as the latter operator is not even part of any class). While the example may seem quite subtle, C++ concepts can define non-message requirements like the existence of an internal type definition in the class. (From C++0x#Concept):

concept InputIterator<typename Iter>
{
  typename value_type;
  typename reference;
  typename pointer;
  typename difference_type;
  // ...
}
that requirement is not a message definition of any kind, but a helper for metaprogramming. I don't believe that this article and Concept (generic programming) should be merged. —Preceding unsigned comment added by 85.49.192.58 (talk) 20:25, 31 October 2007 (UTC)
If I understand correctly, protocol would be more or less synonymous with interface, but not with concept, which, in fact, subsumes protocol because it also defines internal organization of a class, not just its outward appearance. This would indeed be a substantial difference, so I think you have a good point here. GregorB (talk) 13:14, 22 November 2007 (UTC)
Also, in your previous example, an int could be class A and a double could be class B, even though int doesn't have any explicit operator+ (it's built into the compiler), and int wouldn't be explicitly "implementing the addable-with-B interface". I believe that's another important difference with interfaces. 200.127.223.79 (talk) 03:10, 1 June 2008 (UTC)