top | item 36666092

(no title)

padobson | 2 years ago

The core usefulness of OOP is usability.

This is the reason I find it useful. To me, OOP is as much about your organization as it is about the best way to load, transform, present, edit, and store data. I think the culture of some companies lends itself to various kinds of programming, but it's the cultureless companies where OOP is most useful. The places where nobody is trying to change the world, where people work to pay their mortgages, where an executive may only work for two years and a programmer may only work for six months.

It's in an environment like that where a self-documenting, self-configuring code base with custom classes and exceptions that guide the next developer is essential.

Every developer should have two users in mind. The person using the software, and the next developer who maintains the software after you're gone. OOP is a great way to empower the second user when the only thing that will reliably outlive the developer is the code base.

discuss

order

Hermitian909|2 years ago

I think that OOP is the best way to accomplish the goals you list only if you stick to languages with mainstream appeal - but think it's sad that's the state of the world. Objects (as they are used in e.g. Java) default to stateful and complect data with the methods on that data. I find that most of the time what I want is closer to OCaml's Modules[0] which give me many of the tools of code organization without the complexity with state. (note that OCaml allows objects, so you get a real sense for how often you want an object over a module, 95% of the time I wanted a module).

Maybe one day modules will hit the mainstream.

[0] https://ocaml.org/docs/modules

jghn|2 years ago

This is one thing I like about Scala. While its classes can be used in the exact same manner as Java, that's not how its creators pitch them. I've seen them advocate using classes/objects akin to ML's modules, but there's enough flexibility to pivot if for some reason that does not make sense.

dial9-1|2 years ago

you can accomplish that with just modules and functions

marcosdumay|2 years ago

I'd say that all that (modern style) OOP does for organizing code comes from its copying earlier module systems. There is really nothing else there.

Consultant32452|2 years ago

I want to second the idea that the primary benefit of OOP is logical organization.

For smaller projects I don't care one way or another about OOP practices, but once you start getting into hundreds of thousands of lines of code IMO it becomes an absolute necessity.

jbreckmckye|2 years ago

But we don't need classes, vector tables, or other runtime features to achieve organisation. We just need our compiler to recognise namespaces. "module Foo where"