this post was submitted on 10 Feb 2026
294 points (95.4% liked)

Programmer Humor

29671 readers
785 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Wirlocke@lemmy.blahaj.zone 3 points 6 hours ago* (last edited 6 hours ago)

I've moved away from Classes in general unless it truly makes code more streamlined. The main language I was taught in highschool was Java and it's just so liberating not needing to turn everything into an object.

But recently I've used a Class specifically for Inheritance. I'm making an extension to Pytorch and almost everything in Pytorch uses Tensors as a medium. I made a new kind of tensor that inherits the Tensor class to add specific restrictions on how it behaves. Because of this, this new tensor object can be used with any of the preexisting pytorch functions while also validating the results, reverting to a Tensor if it becomes invalid.

Even in this situation though, all my programming logic rests in it's own static functions, and the class contains functions that call the static version. The only actual logic the inherited object handles is validating the data.

Because of this, I feel like inheritance is most useful when you're inheriting someone else's code to make it compatible with their library. I don't think I'll ever inherit my own objects because that's how you end up with Java.