What is protocol-oriented programming?

Asked

Viewed 361 times

3

I would like to know, what is protocol-oriented programming? I heard a teacher comment about this type of programming, about this paradigm, but it was a little vague.

  • 1

    https://developer.apple.com/videos/play/wwdc2015/408/

  • 1

    Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.

1 answer

4

It is vague because there is no formal definition, it is not universally accepted. Swift is a language that uses protocols to generalize operations, and in the background protocols are interfaces in other languages, with, small differences. So the term refers to this, which is strange because just a mechanism to name a whole paradigm seems exaggerated to me, so outside the domains of Apple languages nobody talks about it. Objective C also uses.

The protocol is like an interface with standard implementations, more or less as they occur in Java 8, Kotlin and C# 8. It is a limited form of inheritance and polymorphism, almost like a trait. But it goes beyond and works as an extension of types per value.

Perhaps they wanted to use another name so as not to confuse with interface when it did not accept implementation. At this point it would even be more correct and interface is now a wrong term, but it will not change because it is rooted in the technologies that use it, even after the mechanism changes. Strictly when they changed the mechanism they should change the name, but it was more pragmatic to do so.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.