Earlier quoted context omitted.
That doesn't make sense.
Do you ever use profanity? When do you use it, about which topics?
Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)
71–80 of 113 posts
Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)
#72Earlier quoted context omitted.
Are you sure? His argument is one simple paragraph: The `Car extends Vehicle` or `Duck extends Bird` type of tutorial obscures more than it illuminates. In good OO programming, we don’t make class hierarchies in order to satisfy our inner Linnaeus. We make class hierarchies in order to simplify the code by allowing different parts of it to be changed independently of each other, and to eliminate duplication (which co…
Indentation breaks HN. Blockquote should not inherit from Codeblock. Please remove it and use > for quotes. > The `Car extends Vehicle` or `Duck extends Bird` type of tutorial obscures more than it illuminates. In good OO programming, we don’t make class hierarchies in order to satisfy our inner Linnaeus. We make class hierarchies in order to simplify the code by allowing different parts of it to be changed independe…
As it stands, > does nothing on HN, so we're treated to endless complaints about people misusing code blocks for quoting. The complaints are valid, since code blocks don't work properly on mobile. Complain enough about either of these issues and they'll gripe at you for complaining. It never occurs to them that fixing the problems would avoid both the need for complaining and the need for griping. Oh, well, life goes on.
Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)
#73>In good OO programming, we don’t make class hierarchies in order to satisfy our inner Linnaeus. This correctly identifies one of the worst problems with how people construct OO programs when they get out of college. They are infected with the idiotic desire to make neat taxonomies. They don't know why. They can't even explain the rules that make one taxonomy good and another one bad. They just feel some immense pres…
Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)
#74>In good OO programming, we don’t make class hierarchies in order to satisfy our inner Linnaeus. This correctly identifies one of the worst problems with how people construct OO programs when they get out of college. They are infected with the idiotic desire to make neat taxonomies. They don't know why. They can't even explain the rules that make one taxonomy good and another one bad. They just feel some immense pres…
Well said. And #3 is also an area where Functional Programming falls completely flat. There is simply no easy way in any FP language that I know to capture such a simple mechanism as: "Reuse 90% of this piece of code but alter just this 10%". Specialization is a very, very powerful aspect of OOP, one that's extremely easy to explain and which comes in handy to model a surprisingly wide variety of problems.
ML modules have modules and functors, which can exactly mimic this and in fact can be even more flexible because they are structurally rather than nominally typed.
Clojure can get some of this via multimethods, but it's not quite the same thing.
Haskell has Backpack. This is fairly new, but takes an approach similar to ML modules. (Interestingly enough to your point elsewhere in this thread, this is a good example of how type classes were not sufficient for this use case).
Scala has it, but that's cheating :). Although it does have a really cool thing which is that every object instance is itself an importable package, which leads to some really nice code reuse at times.
Stepping back, I actually think "Reuse 90% of this piece of code but alter just this 10%" is actually best captured just with splitting things up into functions/procedures in imperative and functional programming languages, rather than building a large class hierarchy, but that's another story altogether.
EDIT: I suppose what you're talking about specifically is overriding an already implemented method, which you can get via module name shadowing and re-exporting of a parent module as Hermitian909 points out elsewhere.
Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)
#75Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)
#76>In good OO programming, we don’t make class hierarchies in order to satisfy our inner Linnaeus. This correctly identifies one of the worst problems with how people construct OO programs when they get out of college. They are infected with the idiotic desire to make neat taxonomies. They don't know why. They can't even explain the rules that make one taxonomy good and another one bad. They just feel some immense pres…
> 3. Often you want to use the default protocol implementation with some changes. Instead of re-implementing the rest of the protocol, it's highly convenient to be able to specify only the differences. > #3 is the core reason why inheritance was developed. No, absolutely not. As sibling comments say, composition is sufficient for that. I can only see exactly one reason why inheritance is necessary: to allow superclas…
Secondly, OO composition does not solve the problem I described in #3. If object X has 9 methods I want to reuse in object Y, making X a component of Y still requires me to re-implement those 9 methods in Y, even if they are just pass-throughs.
Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)
#77I've even seen OO tutorials which make it explicit to give the bad advice that all your objects should match real world _things_.
This does not match my experience of OO programming or what the actual challenges or rewards are:
> We make class hierarchies in order to simplify the code by allowing different parts of it to be changed independently of each other, and to eliminate duplication (which comes to the same thing). Without any context as to what the code needs to accomplish, you can’t make a judgment about whether a particular design decision is good or bad.
YES.
Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)
#78Earlier quoted context omitted.
“Geez” is a minced oath designed specifically to avoid blasphemy—avoiding it by a millimeter, to be sure. Even some devout Christians say things like “gosh”, “darn”, and “geez”.
"Overhead, without any fuss, the stars were going out" I once knew a baptist preacher who was a serious student of theology and moral philosophy. He liked to discuss the distinction between theology and law, particularly when framing behaviour as the imperative expression of faith, and not faith as the expression itself. Needless to say, the parishioners loathed him and he was hounded out for exposing their constant…
Some Christians aren't in favor of cursing in general, even if it's not blasphemous. My best understanding is that they feel that it expresses a lack of gratitude for the blessings they have—that, at least for a moment, you are forgetting that every moment of life is a miracle, allowing yourself to become enslaved to your wrath, which is of course a sin in standard versions of Christianity. (This does of course pose some difficulties to reconcile with the stories of cursing the fig tree and the money changers, which the Christians resolve in various creative ways.)
Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)
#79>In good OO programming, we don’t make class hierarchies in order to satisfy our inner Linnaeus. This correctly identifies one of the worst problems with how people construct OO programs when they get out of college. They are infected with the idiotic desire to make neat taxonomies. They don't know why. They can't even explain the rules that make one taxonomy good and another one bad. They just feel some immense pres…
Well said. And #3 is also an area where Functional Programming falls completely flat. There is simply no easy way in any FP language that I know to capture such a simple mechanism as: "Reuse 90% of this piece of code but alter just this 10%". Specialization is a very, very powerful aspect of OOP, one that's extremely easy to explain and which comes in handy to model a surprisingly wide variety of problems.