Live data from Hacker News

Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

web.archive.org

61–70 of 113 posts

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

#61
post #42

Geez, chill out. I can't stand profanity.

Pot, kettle, black. Blasphemy is a subclass of profanity.

“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”.

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

#62
post #42

Geez, chill out. I can't stand profanity.

Pot, kettle, black. Blasphemy is a subclass of profanity.

Fun fact, “golly” is a contraction of “god’s body” which at one point was among the highest of blasphemies. Implying that the Creator was corporeal, that’s a paddlin’

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

#63
post #61

Earlier quoted context omitted.

Pot, kettle, black. Blasphemy is a subclass of profanity.

“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”.

Yeah it’s gaming the system. Like children saying I was Born on a Pirate Ship while holding their tongue.

Or Miss Mary had a Steamboat. You know exactly what you’re doing and you ain’t foolin anyone.

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

#64
post #52
post #45

Earlier quoted context omitted.

I don't mean this in a gatekeeping way, but if you've never been inspired to use profanity by an OO design, you probably aren't yet in the target audience.

That doesn't make sense.

Do you ever use profanity? When do you use it, about which topics?

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

#65
post #63
post #61

Earlier 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”.

Yeah it’s gaming the system. Like children saying I was Born on a Pirate Ship while holding their tongue. Or Miss Mary had a Steamboat. You know exactly what you’re doing and you ain’t foolin anyone.

Profane and sacred language is a curious thing.

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

#66
post #61

Earlier quoted context omitted.

Pot, kettle, black. Blasphemy is a subclass of profanity.

“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 hypocrisy. Also possibly for declaiming in classical Greek on a Sunday morning; he was truly a latter-day Socrates.

My wife and I recently re-watched that unfortunately truncated classic, HBO/BBC/Rai's Rome, and were once again thoroughly entertained by the multitude of colourful epithets. Sadly, exclaiming "by Juno's cunt!" during a contentious meeting of the audit sub-committee or weekly retro would require more explanation than I'd care to give in context. And yet, a devout Christian should have no problem with this, at least on a theological level, since no scripture is violated.

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

#67
post #49

Earlier quoted context omitted.

Not sure what you mean, exactly. Could you sketch a simple example with some types and typeclasses?

This is how it would be done in Java: class Parent { public void first() {}; public void second() {}; public void third() {}; } class Child extends Parent { @Override public void third() {}; //change implementation of third function, reusing the first two. }

third = first + second

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

#68
post #49

Earlier quoted context omitted.

Not sure what you mean, exactly. Could you sketch a simple example with some types and typeclasses?

This is how it would be done in Java: class Parent { public void first() {}; public void second() {}; public void third() {}; } class Child extends Parent { @Override public void third() {}; //change implementation of third function, reusing the first two. }

I would accomplish this in modules in the following way. I use reasonML syntax but it's OCaml under the hood

  module Parent {
    let first = () => ();
    let second = () => ();
    let third = () => ();
  };

  module Child {
    include Parent; //add parent funcs to namespace
    //@Override 
    let third = () => ();
  };

I make regular use of this pattern production.

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

#69

Earlier quoted context omitted.

These days I find composition via dependency injection (of interfaces, not concrete implementations) to be a much better way to solve #3.

I would argue you should inject concrete implementations until you need an interface. Why add unnecessary indirection?

It lets you constrain your logic code to depend as loosely as possible on its dependencies.

If I start from a concrete 'FooDatabase' (and wait until later to interface it), I might start putting things like open(), close(), flush(), etc. into my logic code. Then when I interface it, it will just be unnecessary indirection.

If I start from the other end and think "I just need somewhere to put my Foos", then I'll pass in a Consumer and be done with it.

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial (2011)

#70
post #29

Earlier quoted context omitted.

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%". Haskell’s typeclasses and OCaml modules solve this problem neatly. It is not as easy as in Java, because you need to spend a few minutes thinking how to abstractly specify the interface yo…

> Haskell’s typeclasses and OCaml modules solve this problem neatly. Neither do, really. Imagine you have an existing typeclass with three functions. How do you create your own typeclass that reuses two of these three functions but your own instance reimplements the third one? Try it. It's pretty much impossible, or at least not without a lot of boilerplate and forwarding.

Do you mean your own instance of a typeclass? Because that's the direct Haskell analogy to a subclass in Java. I'm not sure where the difficulty is here, as what you're describing is quite straightforward. You can also have the same type be an instance of as many typeclasses as you want, which is something that inheritance-based subclassing and tree hierarchies (is-a rather than has-a) has always made awkward.

> Reuse 90% of this piece of code but alter just this 10%

There is no general solution to this, in any programming language, without some foresight (unless you admit some crazy features like arbitrary code re-writing or source-level patches). If you have, say, a single function of 100 lines, and 10 lines need to be changed, you're going to have to edit that code to enable the change, and if that 100 lines is in a third-party library or code you otherwise don't control, you're going to have a hard time. However, if you control the code and are able to make changes to it to support new behaviors, FP languages give you plenty of power here, just as OOP languages do. There's not a lot of objective difference here in power and plenty of differences in taste and familiarity, so please be careful about repeating "you can't do X in language Y".

Post reply on HN