331
OOP at home: (feddit.nu)
top 50 comments
sorted by: hot top controversial new old
[-] rain_worl@lemmy.world 0 points 6 days ago

c, can i have a object oriented programming
c: no, we have object oriented programming at home.
object oriented programming at home: struct

(??)

[-] tiramichu@sh.itjust.works 176 points 3 weeks ago

I'll say this now.

Inheritance is the most misused capability of OOP which programmers think makes their code look smart, but most of the time just makes a giant fucking mess.

[-] red_tomato@lemmy.world 105 points 3 weeks ago* (last edited 3 weeks ago)

Hold on, I’m in the middle of drawing an inheritance graph so I know how Dog is related to AircraftCarrier.

[-] blackn1ght@feddit.uk 79 points 3 weeks ago* (last edited 3 weeks ago)
public interface ICanTravelThroughTheAir
{

}

public class Flea : ICanTravelThroughTheAir
{

}

public class AircraftCarrier
{
  private readonly List<ICanTravelThroughTheAir> _aircraft = new();

  public void AddAircraft(ICanTravelThroughTheAir flyingThing)
  {
    _aircraft.Add(flyingThing);
  }
}

public class Dog : AircraftCarrier
{
    public void Woof()
    {
        Console.WriteLine("Bitch I'm an aircraft carrier!");
    }
}

public static class Program
{
  public int Main(string[] args)
  {
    var dog = new Dog();
    
    for (var i = 0; i < 10000; i++)
    {
        dog.AddAircraft(new Flea());
    }

    dog.Woof();
  }
}
[-] jenesaisquoi@feddit.org 64 points 3 weeks ago

Needs more AbstractDefaultProxyBeanFactoryFactories

[-] Supercrunchy@programming.dev 24 points 3 weeks ago

And dependency injection!

Every class needs to use DI for calling other classes, even though we'll have anyway just a single implementation for all of them, and we won't be using this flexibility at all (not even for tests where it might be useful for mocking dependencies).

[-] jenesaisquoi@feddit.org 14 points 3 weeks ago

Methods calling other methods? Heresy! There needs to be two or three interceptors on there, and some indirection over RabbitMQ using spring-integration, at the very least.

This is how you write proper enterprise-level software: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

load more comments (1 replies)
load more comments (1 replies)
[-] Valmond@lemmy.dbzer0.com 10 points 3 weeks ago

Not even unnecessarily templated, B- at best

load more comments (3 replies)
[-] mesamunefire@piefed.social 46 points 3 weeks ago

Its the best/worst thing about OOP no matter what language.

We had a rule at work that if you are 3 levels or more down an inheritance tree, then you are too far. The cognitive load is just too much, plus everything stops making sense.

One level can be great (MVC all have great conventions, MCP as well). Two can be pushing it (Strategy pattern when you have physical devices and cant be connected all the time, Certain kinds of business logic that repeat hundreds of times, etc...) But even there you are kinda pushing it.

I need code that I can look at a month from now and know WTF is happening. And sometimes its better to have less DRY and more comprehension. Or maybe im just a forever mediocre dev and dont see the "light". I dunno.

[-] tiramichu@sh.itjust.works 19 points 3 weeks ago

This is exactly how I feel too. A little bit of repetition is totally worth it, versus having inappropriate coupling, or code that jumps in and out of parent/child classes everywhere so you can hardly keep it in your head what's going on.

I freely accept that I AM a mediocre dev, but if that lends me to prefer code that is comprehensible and maintainable then I think being mediocre is doing my team a favour, honestly.

[-] grendel84@tiny.tilde.website 10 points 3 weeks ago

@tiramichu
It's this mentality that shows you aren't mediocre. Simplicity requires more skill, not less.
@mesamunefire

[-] mesamunefire@piefed.social 4 points 3 weeks ago

Thats kind of you to say 😀

load more comments (3 replies)
[-] fibojoly@sh.itjust.works 10 points 3 weeks ago* (last edited 3 weeks ago)

PTSD flashbacks to the codebase I started on in 2008 which had... I don't even remember. Like six or seven levels. Fucking nightmare. I did a printout of the analysis Doxygen gave me and it ended up as a 4x3 meters poster ;_;

load more comments (1 replies)
[-] firelizzard@programming.dev 7 points 3 weeks ago

When I first started using Go I bemoaned the lack of true inheritance and classes. Now I love it.

load more comments (3 replies)
[-] calcopiritus@lemmy.world 6 points 3 weeks ago

But if I have to make an Array I have to inherit from Indexable which inherits from Collection which inherits from Object! How else am I supposed to implement an Array?

[-] SparroHawc@lemmy.zip 4 points 3 weeks ago* (last edited 3 weeks ago)

Admittedly this is why I like C#'s 'implements' paradigm. Doesn't have to inherit, it just has to fulfill the contract, and then you can pass it to anything that expects the interface it implements. Keeps you from building giant trees.

load more comments (2 replies)
load more comments (1 replies)
load more comments (3 replies)
[-] Nioxic@lemmy.dbzer0.com 10 points 3 weeks ago

I learned about it in school and we didna few assignments for it

But.. never seen or heard anyone mention it outside of that

I guess we can make up some nische vases

I did hear it can be useful for video games though. But then again im sure people can manage fint without, as well

[-] Valmond@lemmy.dbzer0.com 14 points 3 weeks ago

It's wildly useful, when you store a lot of similar stuff, or treat a lot of similar stuff etc.

Like a GUI, a rendering engine or a scientific soft. Video games, any soft with users, and so on.

I get that people misuse it but for me it's wild that people think you should like program without it, like at all cost.

[-] Railcar8095@lemmy.world 6 points 3 weeks ago

We use it a lot when we have a solution that works for 95% of customers and a few need random things.

Else we will have multiple markets changing the same function with a thousand if else

Main issue is that makes it so that some functions are never generalized, like when customer A wanted to use an equal filter, customer B wanted a IN filter, and the rest have no filtering capability at all.

[-] abbadon420@sh.itjust.works 7 points 3 weeks ago

Aggregation > composition > inheritance

load more comments (1 replies)
[-] Wirlocke@lemmy.blahaj.zone 5 points 3 weeks ago* (last edited 3 weeks 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.

load more comments (2 replies)
[-] tatterdemalion@programming.dev 81 points 3 weeks ago

In over ten years of professional programming, I have never used inheritance without regretting it.

When it's the right tool, it's incredibly useful. When it's the wrong tool, and it often is, it racks up tech debt at an incredible rate.

It works great for technical constructs. E.g. A Button is a UI element. But for anything business logic related, yeah it'll suck.

[-] FooBarrington@lemmy.world 7 points 3 weeks ago

Even then there's rarely a good reason to use inheritance instead of composition.

[-] red_tomato@lemmy.world 20 points 3 weeks ago

And not once have I regretted removing inheritance.

[-] Supercrunchy@programming.dev 6 points 3 weeks ago

It might be nice to use in some very specific cases (e.g. addition-operation is a binary-operation AST node which is an AST node).

In most of the cases it just creates noise though, and you can usually do something different anyway to implement the same feature. For example in rust, just use enums and list all the possible cases and it's even nicer to use than inheritance.

[-] Valmond@lemmy.dbzer0.com 4 points 3 weeks ago

That's wild. What did you use it for?

load more comments (6 replies)
load more comments (4 replies)
[-] jenesaisquoi@feddit.org 65 points 3 weeks ago

Composition over inheritance every day, all day

[-] RustyNova@lemmy.world 61 points 3 weeks ago* (last edited 3 weeks ago)

I LOVE TRAITS. YOU'LL HAVE TO TAKE THEM FROM MY COLD DEAD HANDS

[Insert SpongeBob screaming meme]

[-] PlexSheep@infosec.pub 9 points 3 weeks ago

TRAITS ARE SO USEFUL AND STRUCTS ARE EASILY REPRESENTED IN MEMORY AND WORKED WITH, COMBINED THEY WILL TAKE OVER THE LINUX KERNEL AND THE WORLD

[-] xep@discuss.online 4 points 3 weeks ago

SORRY ARE WE WRITING IN ALL CAPS BECAUSE SOMETHING ABOUT TRAITS REQUIRES IT OR IS IT BECAUSE I'M HARD OF HEARING?

load more comments (1 replies)
[-] kibiz0r@midwest.social 49 points 3 weeks ago

The venerable master Qc Na was walking with his student, Anton. Hoping to prompt the master into a discussion, Anton said "Master, I have heard that objects are a very good thing - is this true?" Qc Na looked pityingly at his student and replied, "Foolish pupil - objects are merely a poor man's closures."

Chastised, Anton took his leave from his master and returned to his cell, intent on studying closures. He carefully read the entire "Lambda: The Ultimate..." series of papers and its cousins, and implemented a small Scheme interpreter with a closure-based object system. He learned much, and looked forward to informing his master of his progress.

On his next walk with Qc Na, Anton attempted to impress his master by saying "Master, I have diligently studied the matter, and now understand that objects are truly a poor man's closures." Qc Na responded by hitting Anton with his stick, saying "When will you learn? Closures are a poor man's object." At that moment, Anton became enlightened.

[-] bleistift2@sopuli.xyz 14 points 3 weeks ago

Should’ve listed the source. Bad commenter.

[-] kibiz0r@midwest.social 23 points 3 weeks ago

Source: https://wiki.c2.com/?ClosuresAndObjectsAreEquivalent

(Sorry dude, my time was limited by how long I could spare poopin in-between meetings.)

[-] Flipper@feddit.org 41 points 3 weeks ago

Deref is for smart pointers and not for inheritance.

[-] Phoenix3875@lemmy.world 23 points 3 weeks ago

Let me introduce you to this horror story: Deref Polymorphism https://rust-unofficial.github.io/patterns/anti_patterns/deref.html

load more comments (2 replies)
[-] FreshLight@sh.itjust.works 38 points 3 weeks ago* (last edited 3 weeks ago)

In case anyone is wondering:

The artist is Princess Hinghoi.

[-] Not_mikey@lemmy.dbzer0.com 32 points 3 weeks ago

Looks like some circular inheritance, that's going to cause some issues down stream.

load more comments (1 replies)
[-] FEIN@lemmy.world 21 points 3 weeks ago

sometimes i wonder what dignity means to certain artists

[-] FreshLight@sh.itjust.works 18 points 3 weeks ago* (last edited 3 weeks ago)

My guess is that money overwrites dignity in some cases.

load more comments (1 replies)
[-] Gonzako@lemmy.world 11 points 3 weeks ago
[-] FreshLight@sh.itjust.works 13 points 3 weeks ago
[-] Gonzako@lemmy.world 10 points 3 weeks ago

I'm taking the blonde with the succubus tattoo

load more comments (2 replies)
[-] NigelFrobisher@aussie.zone 15 points 3 weeks ago* (last edited 3 weeks ago)

Examples of inheritance hierarchies are always totally useless shit like this - what if a cow is an animal; What if a cow is a mammal, all mammals are animals and all mammals have a lactate() method?

[-] jason@discuss.online 11 points 3 weeks ago

Yeah... Wheres the AbstactAnimalFactoryManager?

load more comments (1 replies)
[-] ulterno@programming.dev 10 points 3 weeks ago

Because any real life use that might come to mind would probably be related to some NDA protected database in a company.
And it is otherwise hard to think of anything at the spot, so just go with what the first example on the web-search came up with.

[-] ZILtoid1991@lemmy.world 13 points 3 weeks ago

Entity Component System all the things!

I might write an XML ECS parser, as a joke. Practical? No! Probably even slower than the XML DOM? Yes! Funny? Yes!

load more comments
view more: next ›
this post was submitted on 10 Feb 2026
331 points (95.8% liked)

Programmer Humor

30224 readers
324 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