this post was submitted on 03 Jul 2023
6 points (100.0% liked)
Programming
355 readers
1 users here now
This magazine is dedicated to discussions on programming languages, software development, and coding. Whether you are a beginner programmer or an experienced developer, this is the place for you. Here you can share your knowledge, ask questions, and engage in discussions on topics such as coding languages, software engineering, web development, and more. From the latest trends and frameworks to tips and tricks for debugging, this category covers a wide range of topics related to programming.
founded 2 years ago
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
These "OOP is bad, here's why" type of articles often can be simplified to the pattern of "here's a terrible example of OOP, and here's a very good functional solution of the same problem".
On small scale, OOP just makes things way more complicated than it should be. On larger scale however, it works quite well, especially if you know where to break the rules.
Something doesn't need inheritance? Don't use it! I even use structs in D, which often speed up things by a lot, especially since they're not ref by default.
One big issue I've seen to come up again and again is the programmer not knowing how to handle functions, that need to be called many times. By conventional OOP wisdom it's done something like this:
However, we can move the iteration into the function of the class, so we will still have the power of class interchangeability:
Inheritance can replace complex condition statements. The class
Foo
in my example could be a basis for a thing, that has its own internal state, which is pretty common in game development. However most people are not being taught game development, but instead things that assumed to make money, which include the hottest new trend. When I was beginning to learn programing in college, I was told that we can say goodbye to .exe files, to say goodbye to installing programs to your PC, because everything is going to be web based, thanks to... Flash??? And Java applets??? Funny, it turned out to be JavaScript to be the winner, and now we have applications on our computers that are just glorified Chromium browsers running what are essentially interactive web pages, which got so widespread there are now coders not only afraid of all pointers, but also type declarations.In my honest opinion:
goto
statements, it was revolutionary. However, we might never replicate its impact yet again in our lifetime. Maybe it'll never be replicated ever again. People are already failing to find the next iPhone, which are just nicer looking PDAs.const
everywhere. And so on, and so on, and so on.Yeah. I read a lot less about large FP codebases than about large OOP codebases. Wonder why. /s
Some things just can't be properly seen and evaluated in a tiny made-up example that fits in a blog post.
Plus, you have large teams with devs of different skills. Will they all be able to use the wonderful functional idioms that solve all problems and make everything great? Looks like more devs are able to use OOP, warts and all, to create some workable projects. Even if not supremely elegant.