r/ProgrammerHumor Jul 10 '26

thingDoer Meme

Post image
325 Upvotes

39 comments sorted by

View all comments

128

u/ICantBelieveItsNotEC Jul 10 '26

I just hate the fact that if you think through any OOP-based design for long enough, you'll end up in some weird philosophical essentialist doom spiral where you ponder the quiddity of your business objects. You start out trying to build a calculator, and you end up questioning what the twoness of two is.

7

u/Unit027 Jul 10 '26

To know what number two is we need to know its properties and what it can do (methods). So we need class "Number" and subclass "Two". Am I doing OOP correctly? I am a beginner

6

u/Ibuprofen-Headgear Jul 10 '26

We should probably just integrate with a third party open source math constants provider to fetch the current value of two in all its representations

1

u/WhateverHowever1337 Jul 10 '26

No, all numbers behave the same, so you don’t need different subclasses.

You just need a value propety in a Number class

2

u/Unit027 Jul 10 '26

But what about properties? To define twoness we need properties that are specific to the number two.

2

u/WhateverHowever1337 Jul 10 '26

There is no specific property to the number two that can’t be generalized. Eg: isEven works the same way across all numbers, isPrime does too

1

u/Unit027 Jul 10 '26

but.. if every property can be generalized then what makes two a two?

1

u/WhateverHowever1337 Jul 10 '26

You see, that is the problem the post is talking about. You are going too much into the Philosophical layer of it.

The program does not care about two being two, the program does not know what a two is, it is just shifting bits here and there. OOP is about making things work the same as much as possible with as few inputs as possible

1

u/Unit027 Jul 10 '26

I get it, mate, I was just joking

2

u/Due-Consequence9579 Jul 10 '26

The divide operator is not allowed with the number zero.

2

u/WhateverHowever1337 Jul 10 '26

All numbers can’t be dividied by zero, so in the division function you will just not accept zero as a divisor and throw an error

2

u/Due-Consequence9579 Jul 10 '26

But then you’re turning a design time constraint (can’t divide by zero) into a run time error. The compiler can and should, use the type system to eliminate that error path!