8 ms·
AKA python style OOP ;-)
by mollerhoj 5y ago
AKA python style OOP ;-)
- PaulHoule 5y agoEven in a language like Java which pushes objects pretty hard the mental model that "a method is just a function where the first parameter is this" is pretty useful, particularly if you are trying to break out of the OO box and write Java code that looks like LISP, ML, COBOL, FORTRAN, etc. (Super Fun IMHO, particularly in JDK 17!) The tricky thing with this model is "how do you implement polymorphism?" The most sublime methods dispatch not just on this but also on the other methods but you do get extra complexity just as you would with multiple inheritance, or the C++/C# polymorphism models other than Java's "all-virtual" approach, etc.