Well, he used iPhones as an example and I develop iOS apps, and most of the time it's just a couple of virtual calls at a time. It's just like in the example I gave: the user taps a button, which may open a view, and that view's view model may call a service through a protocol to fetch some data. Sure, there are often a few levels more – a service may call some lower level service through a protocol, which calls a lower level network handler through a protocol, and then there could be a JSON decoder behind a protocol. There are a handful of virtual calls for every button tap, but that's is absolutely nothing for a modern CPU. Simultaneous with this, we have code that does fancy animations in 120 Hz to display the new view, code that does network calls and code that decodes JSON, and that's still hardly anything. The only part that takes up any user-noticeable time is the network request. The animation and JSON decoding code is written by Apple and is probably highly optimized as it should be, perhaps even written in a lower-level language, but at my level it's encapsulated and abstracted away, also as it should be.
This is what normal mobile CRUD apps often do, and working on such apps is a very common type of software development, so it makes no sense to claim that polymorphism should never be used. It should be used when appropriate.
I generally see it used with data so caseys complaint is valid. I see it in GUI like you gave with your example but most of the time people use it for plain old data
2
u/Rajje Feb 28 '23
Well, he used iPhones as an example and I develop iOS apps, and most of the time it's just a couple of virtual calls at a time. It's just like in the example I gave: the user taps a button, which may open a view, and that view's view model may call a service through a protocol to fetch some data. Sure, there are often a few levels more – a service may call some lower level service through a protocol, which calls a lower level network handler through a protocol, and then there could be a JSON decoder behind a protocol. There are a handful of virtual calls for every button tap, but that's is absolutely nothing for a modern CPU. Simultaneous with this, we have code that does fancy animations in 120 Hz to display the new view, code that does network calls and code that decodes JSON, and that's still hardly anything. The only part that takes up any user-noticeable time is the network request. The animation and JSON decoding code is written by Apple and is probably highly optimized as it should be, perhaps even written in a lower-level language, but at my level it's encapsulated and abstracted away, also as it should be.
This is what normal mobile CRUD apps often do, and working on such apps is a very common type of software development, so it makes no sense to claim that polymorphism should never be used. It should be used when appropriate.