Protocol (Object-oriented Programming)

In computer science's object-oriented programming, a protocol (Java: interface) is what or how unrelated objects use to communicate with each other. These are definitions of methods and values which the objects agree upon in order to cooperate. For example, in Java (where protocols are termed interfaces), there is the Comparable interface specifies a method compareTo() which implementing classes should implement. So, this means that a separate sorting method, for example, can sort any object which implements the Comparable interface, without having to know anything about the inner nature of the class (except that two of these objects can be compared by means of compareTo()). The protocol is a description of:
  1. the messages that are understood by the object,
  2. the arguments that these messages may be supplied with, and
  3. the types of results that these messages return.
  4. the invariants that are preserved despite modifications to the state of the object
  5. the exceptional situations that will be required to be handled by clients to the object
If the objects are fully encapsulated then the protocol will describe the only way in which objects may be accessed by other objects. Programming languages that support protocols: Objective-C, Java, C#, D Note that functional programming and distributed programming languages have a concept which is also called protocol, but whose meaning is subtly different (i.e. a specification of allowed exchanges of messages, emphasis on exchanges, not on messages). This difference is due to somewhat different assumptions of functional programming and object-oriented programming paradigms. In particular, the following are also considered as part of a protocol in these languages:
  1. The allowed sequences of messages
  2. Restrictions placed on either participant in the communication
  3. Expected effects that will occur as the message is handled
See also: class, encapsulation, public interface, private interface

 

<< PreviousWord BrowserNext >>
temporary autonomous zone
list of blues musicians
mesonic atom
list of ragtime musicians
juniper
robert clive, 1st baron clive
hbo latino
tri nations series
smartruck i
leo cruz
eleanor hibbert
great ape personhood
p. c. doherty
list of folk musicians
kyrgyzstan
old enough
natural experiment
lisa kudrow
david schwimmer
la bourdonnais
aleksandr kolchak
paraaque city
canton of schwyz
preference
muntinlupa city
fermi energy
king of sweden
parabolic microphone
list of people by belief
role
the dam busters (movie)
rabbits in australia
concerto grosso
stepper motor
dc
snot
cog
sounds of silence
grammy awards of 1971
total football
midori
brampton lake
top 40
ohana