Talk:Interface (object-oriented programming)

message: 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)
replies: text: Exactly what I perceived about "protocol"! Protocol should be about the behaviour, about the (abstract) state of the system/object. In particular, it should tell the user/client how to use the object, in what order the methods must be called, not just what methods the object provides. Lê Harusada (talk) 03:45, 30 October 2011 (UTC)

text: I think the historical "weak" sense of "protocol" used by Objective-C and implicitly by SmallTalk was due to the overstatement of the method invocation as "messaging between objects". Thus, the Java's interface simply defines the messaging protocol between objects, even though partially. Hence, I think the good old SmallTalk and Objective-C should be mentioned in the article instead of the mordern Java! Lê Harusada (talk) 05:35, 30 October 2011 (UTC)

text: Support. A "protocol" requires a description of the behavior, of the states at both sides and not merely of messages. The proper term here - IMO - is "interface" / "abstract interface" - to show that the formal specification of (abstract) methods does not qualify for a "protocol", but is only a part of what is possibly a specification of a communication protocol. AFAIK, it has always been "separating interface and implementation", not "separating protocol and implementation". To use "protocol" here is confusing and misleading. 62.178.250.9 (talk) 14:47, 17 March 2014 (UTC)
thread_title: Disputed sense of ''protocol''

message: :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)
replies: text: 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)

text: 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)
replies: text: 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)

text: 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)
thread_title: Merge with ''concepts'' in C++ STL

message: When a programmer says ‘interface’ they almost always mean this unless explicitly prefixed by ‘user’. But when he says ‘protocol’ he'll be talking about http and such. Shinobu (talk) 18:57, 6 September 2008 (UTC)
thread_title:  I think interface is the more common term 

message: This page is clearly the victim of merging by people who are not knowledgeable in the field. A protocol is not the same as an interface. At best an interface might be an element of a protocol. Interface is a common term among computer programmers which denotes a set of method signatures with no included implementation. It has a very clear concrete meaning which is distinct from that of a protocol, which is much more broad. While they might server similar purposes, ie that of abstraction and creation of a contract for the purpose of communication, they are very different animals. They are different in about the same way that a bicycle is different from a freeway. Waylonflinn (talk) 23:04, 7 October 2011 (UTC)
replies: text: This article is meant to be about the object-oriented concept of protocols, no communication protocols. The former are named in analogy to the later but exist independently and are significantly different. I think the Waylonflinn comment you were replying to is a reference to the fact that people are editing this article without a full understanding of the different between object-oriented protocols and interfaces, not a claim that interfaces aren't protocols because they're not communication protocols, even though they indeed are not that either :-). TFJ76 (talk) 11:33, 11 November 2022 (UTC)
thread_title:  Victim of Misunderstanding 

message: Never heard of Interfaces being called Protocols ever, must be only on a few select languages. 200.3.193.162 (talk) 16:01, 8 October 2018 (UTC)
thread_title:  Protocol?