Live data from Hacker News

Was object-oriented programming a failure? (2015)

quora.com

121–126 of 126 posts

Re: Was object-oriented programming a failure? (2015)

#121
post #120

Earlier quoted context omitted.

It's just a demonstration of how the hierarchy works in the abstract. And it's just displaying the price on the meter, not saying the "car" has to deal with that. The driver would, or the player, if you look at this like game code, which would make sense.

Dude, it was just an example for a style discussion. You're missing the point of the discussion and way over-engineering the example.

I'm just saying I don't think the "There is no right answer" statement works here because there seems to be one right answer to me.

Re: Was object-oriented programming a failure? (2015)

#122
post #120

Earlier quoted context omitted.

Dude, it was just an example for a style discussion. You're missing the point of the discussion and way over-engineering the example.

I'm just saying I don't think the "There is no right answer" statement works here because there seems to be one right answer to me.

[deleted]

Re: Was object-oriented programming a failure? (2015)

#123
post #120

Earlier quoted context omitted.

Dude, it was just an example for a style discussion. You're missing the point of the discussion and way over-engineering the example.

I'm just saying I don't think the "There is no right answer" statement works here because there seems to be one right answer to me.

It's weird how inexperienced people are the most rigid and dogmatic. Experienced people know that there are always multiple ways of doing everything.

Re: Was object-oriented programming a failure? (2015)

#124
post #52

One of the common nice features in OOP is polymorphism. You have a list/set/collection of objects which are of the same type, but also of different subtypes. They have the same behavior when calling some method and different behaviors when calling another method. OOP is not a failure. But overengineering is another thing. (Sometimes I heard "Never write static function/method! Do it in OOP way!", though it doesn't ma…

A counter-point to this is that OOP languages lack support for ad-hoc polymorphism. i.e. the ability for third-party code to define an implementation of an interface for a pre-existing type. The two approaches used to work around this are the adapter pattern, and explicitly taking an object implementing the desired behaviour as a second argument (e.g. Comparators in Java).

In contrast, most (typed) FP languages support typeclasses / traits, which makes a lot of code considerably simpler.

Re: Was object-oriented programming a failure? (2015)

#125

Earlier quoted context omitted.

> The problem is that 'functional code' means 'spagetti code' for many 'low skill' people I don't see how that is the case. Even in the most poorly written function you have code that's working mostly on it's arguments (and maybe some global or something, since it is poorly written) and then returns a value. How is this function connected to the surrounding code? We know the answer, it's called in a single expression…

It's not about hidden state; that's just bad OOP. You shouldn't be looking at the internals, that's the point. It's about modular encapsulation and reusable components. > a single isolated function and the functions tend to be on the short side I can almost guarantee that code was not written by an inexperienced or low skill coder. If it was, you'd have a large complex function that took large complex state as its in…

> I can almost guarantee that code was not written by an inexperienced or low skill coder. > If it was, you'd have a large complex function that took large complex state as its input, and probably maintained some kind of hidden internal state in some kind of async deferred loop after it returned or some combination of the above. > Have you worked with inexperienced FP programmers? > It's not fun.

No pure FP language will allow you to do that without the function's type signature reflecting that - it would need to return its value in some kind of state/async monad.

Now, if you're talking about FP in a traditionally OOP language, then I agree with you, but that's an apples to oranges comparison.

> Inexperienced OOP is a lot easier to deal with, because the entity level API validation is all you care about; you don't care about how hideously the internals were implemented as long as the tests pass. There can be any number of bugs and spaghetti inside the object, but you don't care, because you don't see it (until it manifests as bugs; but then you just add more tests and make them go away until all the tests pass).

This approach doesn't work for things that are difficult to test. e.g. you can only ensure your types are thread safe by reasoning about their use of locks, volatile, etc., because any attempt to test this is dependent on the implementation details of your runtime (e.g. the JVM) and the amount of load its under. Best case you get a flaky test, worst case you miss a bug that blows up in production.

But this is a tangent, because TDD is not specific to OOP - it works just as well with FP.

> but the point here is that someone has to define the module level interface, and how it behaves as a state machine (regardless of if the state comes in 'pure' and is passed around or is encapsulated internally); and that's OOP, not an inheritance hierarchy.

Pure state is an oxymoron. The idea is not that you pass a mutable argument in, but that you don't have the ability to mutate data at all. At best, you can return some instructions on how to mutate (e.g. the state monad), but its the consumer of your code who decides what to do with that, which prevents you from hiding side-effects, and simplifies testing.

Defining a module level interface and behaviour is just API design, not OOP.

Re: Was object-oriented programming a failure? (2015)

#126
post #123

Earlier quoted context omitted.

I'm just saying I don't think the "There is no right answer" statement works here because there seems to be one right answer to me.

It's weird how inexperienced people are the most rigid and dogmatic. Experienced people know that there are always multiple ways of doing everything.

If you have to resort to implying lack of experience is the only reason someone wouldn't like your example, that doesn't reflect well.
Post reply on HN