News for hackers. Stuff that matters.
Re:Advice for new software devs who've read all those other ... by lolinder on Wednesday December 20, 2023 @10:12AM (#38709503)
> This whole system only builds one type of object. He thinks that his solution is better because it’s more extensible.

> I can’t make him see why it’s bad.

Schools teach OOP as though adding new types of objects is the norm—like every type of software construct is actually a GUI widget in disguise and we're going to be adding new interoperable subclasses every other week, so we may as well get the infrastructure set up to make that easy.

In most real world applications, the only type of object that behaves that way is, well, GUI widgets. Nearly every other type of construct in a typical system will have at most one implementation at a time (possibly two during a gradual transition). Factories, builders, and the whole design pattern menagerie aren't particularly useful when for the bulk of a system's life they're all just proxies to a single constructor.

I don't know if there's a good way to teach this out of someone besides just letting them experience it, but that's the insight that he needs—different types of code have different maintenance characteristics, and the tools he's been given were developed for a very specific type of code and don't apply here.

Re:Advice for new software devs who've read all those other ... by hbn on Wednesday December 20, 2023 @10:33AM (#38709764)
At least where I went to school, the teaching staff in university CS departments seem to be overrun by guys who haven't actually worked in the software industry since the 90s when OOP was the hot new thing. My theory is they were there when they got to build a bunch of new systems with OOP, but didn't have to stick around for the nightmare of trying to maintain those codebases.
Re:Advice for new software devs who've read all those other ... by Levitz on Wednesday December 20, 2023 @11:33AM (#38710463)
Where I live (Tenth largest city in Spain, so not that big) I'm pretty sure I can track misconceptions about OOP to whoever taught that class in the only university that had a CS degree around here some 20 years ago. I've seen like half a dozen teachers saying the same stuff explained in the same way and I'm sure none of them understand OOP at all. Only one was able to explain why getters and setters ought to be used besides saying "it's the standard" and to provide an actual, reasonable use case for it rather than the tired examples of "Yeah OOP is cool because since both cats and dogs eat and have 4 legs you can keep a lot of the code together rather than duplicate it".

Software development is reliant on self-learning, but still, some education can be outright damaging.

Re:Advice for new software devs who've read all those other ... by red_admiral on Wednesday December 20, 2023 @10:55AM (#38710034)
Entities in game systems tend to behave like that too when the whole thing is under development - but then (a) arguably a monster chasing you around is just a special GUI widget with extra behaviour and hit points; and (b) when things get really complex it doesn't hurt to switch from OOP to ECS for games.
Re:Advice for new software devs who've read all those other ... by bloopernova on Wednesday December 20, 2023 @11:22AM (#38710334)
I don't have a lot of knowledge on ECS, are there any good articles out there that compare it to OOP?
Re:Advice for new software devs who've read all those other ... by skydhash on Wednesday December 20, 2023 @04:16PM (#38713755)
Anything that argues composition versus inheritance.
Re:Advice for new software devs who've read all those other ... by GuestHNUser on Wednesday December 20, 2023 @05:31PM (#38714527)
I recommend reading this book on Data Oriented Design[0] since the underlying reason ECS has been widely adopted is because, written correctly, an ECS system can take full advantage of modern hardware. Most ECS vs OOP blogs come at it from a perspective that I personally find flawed. OOP has the tendency to have objects layed out poorly in memory which prevent programmers from utilizing SIMD instructions[1].

[0] https://www.dataorienteddesign.com/dodbook/

[1] For instance, objects in OOP are typically bundled with other data related to the object. As an example, in OOP a Door object could have float X,Y,Z coordinates, an enum for type of door it is, a bool for opened or close etc. This leads to inefficiencies in cpu cache usage when you are iterating through a list of doors and not using every field of the door object.

See this GDC talk for why this matters in the gaming world: https://www.gdcvault.com/play/1022248/SIMD-at-Insomniac-Game...

Re:Advice for new software devs who've read all those other ... by red_admiral on Thursday December 21, 2023 @06:32AM (#38719205)
This tutorial: http://web.archive.org/web/20120314005352/https://www.richar... although now defunct, makes a good start. Around halfway through there's a heading "Abandoning good object-oriented practice" which gets to the point you're asking about.