News for hackers. Stuff that matters.
Re:Pretending OOP Never Happened by zokier on Friday May 15, 2020 @07:04PM (#23198537)
> every call to a virtual method-- including calls internal to the class-- goes through a dispatch step

why would you make internal methods virtual though?

Re:Pretending OOP Never Happened by bregma on Friday May 15, 2020 @08:08PM (#23199028)
Virtual methods should only be internal methods. There's no point in making the public API have virtual methods. That would be a bass-ackwards parody of proper OO design.
Re:Pretending OOP Never Happened by kragen on Saturday May 16, 2020 @12:08AM (#23200418)
It's common to put virtual methods in a public API; indeed, in Java we have the "interface" construct consisting entirely of public virtual methods and, occasionally, named constants. (In more recent versions it can also include default implementations.) In Golang the only virtual-method mechanism works by means of a similar interface construct, which also only contains public virtual methods.

So, for example, Java's Map is an interface type with, for example, .get() and .put() methods; TreeMap and HashMap implement those methods differently. There are similar things in Smalltalk-80 and the C++ STL.

So clearly you think Java, Smalltalk, and C++ are "a bass-ackward parody of proper OO design." I'm interested to hear what systems you consider paragons of proper OO design.

Re:Pretending OOP Never Happened by zozbot234 on Saturday May 16, 2020 @08:20AM (#23202800)
Interface inheritance is broadly fine though, because it specifically lacks the conflation of "base class" and "derived class" code. The interface can be assumed to directly imply some invariants, and it's easy to see of any implementation whether it respects them. Everything is nicely localized.
Re:Pretending OOP Never Happened by kragen on Sunday May 17, 2020 @03:44AM (#23210412)
I agree, but I didn't interpret the comment I was responding to as objecting to implementation inheritance as such, rather the contrary: they're objecting to an enormously wide category of OO designs which includes not only interface inheritance but also most, but not all, uses of implementation inheritance; for example, the Smalltalk-80 design that lumps inject and select into some abstract base class for containers.
Re:Pretending OOP Never Happened by anonymoushn on Saturday May 16, 2020 @01:18AM (#23200703)
Wait, really? I don't know much about "proper OO design" but am forced to use Java at work. I commonly use classes that have e.g. a virtual public getFoo, then someone's made a RealFooGetter that actually talks to the network and a CachingFooGetter that delegates to another FooGetter and maintains a cache. Should I ask my coworkers to stop doing such things?
Re:Pretending OOP Never Happened by rramadass on Monday May 18, 2020 @12:49AM (#23218474)
No.

You might find the book Program Development in Java: Abstraction, Specification, and Object-Oriented Design by Barbara Liskov and John Guttag very useful for understanding OOD/OOP.

Re:Pretending OOP Never Happened by rramadass on Monday May 18, 2020 @12:43AM (#23218450)
What in the world are you talking about? The whole idea of a Type/Class Hierarchy is based on publicly accessible virtual methods or more precisely, on dynamic dispatch.
Re:Pretending OOP Never Happened by waltpad on Saturday May 16, 2020 @01:27PM (#23205369)
You didn't motivate your claim. Could you elaborate?