Live data from Hacker News

The faster you unlearn OOP, the better for you and your software

dpc.pw

141–150 of 252 posts

Re: The faster you unlearn OOP, the better for you and your software

#141
post #48

Should be pointed out that this refers to C++/Java/Ruby/python style objects, and not smalltalk/erlang style objects, which is a message passing model for data storage.

Could someone enlighten me as to how Java style OOP differs from Smalltalk's variant? I've read the Alan Kay quote on how he's sorry for focusing on objects instead of message passing but I'm still unsure on how Smalltalk is so much better not having used it.

This may not answer your question and may not be 100% correct.

Message passing means that objects have their own data and do not have shared access to it. This makes multi-threading and parallelized code very easy to do because you don't have to worry about data changing unexpectedly. Clojure, and other languages, achieve this by making data immutable, which has a similar effect.

As you mentioned, after Alan Kay used the term "object-oriented" to describe Smalltalk, people focused on the objects instead of the messages and created languages designed around the idea of being object-oriented instead of around message passing (I believe Objective-C and Ruby do message passing), thereby missing the benefit. All OOPLs not based on message passing should die.

Also, unlike Java, Smalltalk has no classes. Any existing object can be used as a template to create a new object.

Re: The faster you unlearn OOP, the better for you and your software

#142
> the Customer concept is just a bunch of data in a tabular form in one or more DataStores, and “business logic” code manipulates the data directly.

where lives this business logic? are different functions accessing the same data and modifying it? problems appears.

Re: The faster you unlearn OOP, the better for you and your software

#143
I think for enterprise type software OOP works well. It easily allows us to re-use code and solve common problems once in a parent class and have that solution easily propagated to child classes.

However, when developing a video game, I ran into quite a few OO design conundrums that IMO were the hardest programming problems to solve in my career. I started looking into data driven design, and while I never changed my code to implement it, it looked like it might have been easier for the video game. I do not know for sure. But I do know that getting OO right in the video game I was implementing was daunting. Maybe I was doing it wrong. The one issue we kept running into was how to design it so that the flow of dependencies flowed in one direction. That is to say, classes should not require references to classes that were higher up the food chain, and vice versa. It sucked when you realize that your Bullet class requires a reference to the BattleField class when the BattleField object was not being passed down through all the intermediate objects that separated the two. I would be willing to say that it could have been poor design, or rather not realizing that dependency earlier in the process to deal with it. But many things we did not know till the requirement or change came up. Then it was programming somersaults to deal with it. Eventually we did get better at re-arranging things as things came up, basically we got used to having to change a lot of the design at a drop of a dime.

I do not know if data driven design would have helped, but it did sound like it was worth a shot. I must admit though, I do remember a data driven program i worked on, and it bothered me how much data had to be passed around that was not relevant to the method/class that was using it. And a lot of data got lumped together out of convenience.

Re: The faster you unlearn OOP, the better for you and your software

#144
post #72
post #47

I'm always confused when people criticize OOP, because most of the time the criticisms they use are just plain bad programming. Or they're using hyperbole that isn't really useful. You want to know why OOP is useful and common? Because it's easy. Easy things allow for faster development, faster onboarding of devs. Humans need a mental models of things and OOP very explicitly gives it. But like most easy things, OOP s…

> You want to know why OOP is useful and common? Because it's easy. With as much proof as you have given, let me offer you a counterargument: it is common because academia loves OOP. It's easy to teach, it's easy to test. It is most decidedly not easy and very often not useful. My favorite example of how everything falls apart in due time is the color of a car. That's it, right? A car has a color. A Porsche Panamera…

>it is common because academia loves OOP.

Maybe we're exposed to different evidence but it seems like academia heavily favors non-OOP such as functional programming. Programmers also make repeated citations to SICP class they enjoyed in college but were forced to deal with OOP when they got a real job. It's the commercial industry that pushed OOP. Universities seem very anti-OOP while commercial businesses like Adobe/Microsoft/Google use OOP languages like C++. Other companies that write back office "enterprisey" software also favor OOP languages like Java/C# over non-OOP such as Haskell. I also remember the 1990s when professional programming magazines had monthly articles evangelizing the new thing called "object oriented programming" and you had full-page ads for Turbo C++ and Microsoft C++ that touted its new OOP features.

>My favorite example of how everything falls apart in due time is the color of a car. That's it, right? A car has a color. A Porsche Panamera might be a "carbon grey metallic" and it's stunning, but that's just one color still. Aye, up until the Mini Cooper tells you they need two colors. This world doesn't fit the OOP straightjacket.

I don't understand why your example as you've constructed it proves what you want it to prove. If we use your "car color" as a text template to test the validity of other computer science ideas:

Database table paradigm:

  create table car (
    vehicle_id varchar(20), 
    color_code varchar(1)
  );
... but a car like Mini Cooper can have more than one color. The world doesn't fit the relational table straitjacket.

Algebraic data types such as product type:

  struct {
    char vehicle_id[20]; 
    char color_code[1];
  };
... but a car like Mini Cooper can have more than one color. The world doesn't fit the algebraic data types straitjacket. The world also doesn't fit structs. It doesn't fit the char data type, or array of chars, and so on.

It seems like your example applies to any and all computer science concepts that attempt to model real-world data so maybe I'm missing something?

Re: The faster you unlearn OOP, the better for you and your software

#145
post #139

Earlier quoted context omitted.

> You want to know why OOP is useful and common? Because it's easy. Try rewriting that without adjectives. Engineers are very convincible, but they need evidence. Personally, I don't find OOP to be particularly useful or easy. Check this out... "I became a much better programmer when I started writing functional code. Now I tend to write OOP code in a functional way, but learning how to do that was and not easy, and…

My problem with OOP is debugging it when things go wrong.

But this is often the result of the good property of OOP software. OOP software is easy to write, and allows for easily abstracting over problems.

The net result is OOP programs tend to be more complex. Not "more complex than equivalent software". More complex. But also more capable, more abstract, easier to extend, at least along foreseen lines, easier to change (although that's mostly a tooling thing I think).

But yes, bigger, more intricate software is more difficult to debug. Also abstractions don't help, because often the problem is that there are edge cases where the abstraction doesn't work. Also debugging with abstractions require you to know and understand what the abstraction does.

Re: The faster you unlearn OOP, the better for you and your software

#146
“OOP apologists will respond that it's a matter of developer skill, to keep abstractions in check.”

In my experience, the proliferation and use of ORMs makes keeping abstractions in check nearly impossible... in fact, I see ORM use as the primary design decision leading to the bastardization and convolution of sound OOP design.

Re: The faster you unlearn OOP, the better for you and your software

#147
post #9
post #6

I read this quickly to see if this was the piece that should convince me. It was not. It is, IMO, a collection of strawmen. People have abused OOP? Yes. But - citing FizzBuzz Enterprise Edition (which is really funny even for us Java/.Net developers because it is so horribly wrong) or writing this - Because OOP requires scattering everything across many, many tiny encapsulated objects, the number of references to the…

> What probably is true however is that a lot of people should unlearn the OOP they learned in school. Can you provide references for proper OOP?

Smalltalk does "OOP" properly because it focuses on message passing, the real benefit of "OOP". Any OOPL that isn't based on message passing is degenerate.

Re: The faster you unlearn OOP, the better for you and your software

#148
I think most people forget that Edsger W. Dijkstra was a computer scientist not a software engineer. He most likely wrote programs, but not build software systems. As much as I've enjoyed most of his writings and musings, one must bear in mind that they most likely apply to programs not software systems built in the large. If you are writing one little program and have one type of data, it's easy to begin with data. When you have a complex system operating on 500 different types of data, it becomes easier to encapsulate with OOP.

Re: The faster you unlearn OOP, the better for you and your software

#149
post #47

I'm always confused when people criticize OOP, because most of the time the criticisms they use are just plain bad programming. Or they're using hyperbole that isn't really useful. You want to know why OOP is useful and common? Because it's easy. Easy things allow for faster development, faster onboarding of devs. Humans need a mental models of things and OOP very explicitly gives it. But like most easy things, OOP s…

> I'm always confused when people criticize OOP, because most of the time the criticisms they use are just plain bad programming

Every paradigm can implement any type of program needed, in principle. The point of criticising a paradigm is to argue to what extent that paradigm encourages that bad programming you mention. If OOP naturally frames problems in a way that leads most people to bad solutions for common problems, that's a legitimate criticism.

Re: The faster you unlearn OOP, the better for you and your software

#150

Earlier quoted context omitted.

(monster, weapon, damage) is "the object". And yes, the procedure probably has "side effects". Because that's the point. > Not to mention, just from the signature, that's going to be an absolutely huge procedure. How do you intend to write less code with OOP?

>(monster, weapon, damage) is "the object". Now an environment flag causes fire damage to deal +10% more. You're either going to have to extend the hit method again (further complicating it), or just pull that flag from the environment class in the procedure body itself (undeclared dependency). When something else outside monster/weapon/damage/environment has to change the hit calculations, you'll have to extend it a…

> When something else outside monster/weapon/damage/environment has to change the hit calculations

When something should change, you edit the freakin' code. There is no way around it. If you have different kinds of hits then you make different procedures. e.g. magicPixieDustHit(monster, pixieDust, weapon, damage).

> Side effects are terrible for maintenance and debugging

FP apologetists want to make you believe that, but side effects are the actual point of the program.

> The point is for it to be more human readable

   hit(player, weapon, monster)

   Player.hits(Monster).with(Weapon)
I mean at least acknowledge that that's a highly subjective statement...
Post reply on HN