this post was submitted on 14 Nov 2024
48 points (88.7% liked)

Programmer Humor

32464 readers
139 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] -4 points 13 hours ago (6 children)

Good, OOP can suck my balls

[–] [email protected] 6 points 9 hours ago (5 children)

Balls.suck() is the correct syntax.

[–] [email protected] 3 points 9 hours ago (4 children)

Don't you need to declare new Balls() first? Or do you suck() Balls static?

[–] [email protected] 7 points 8 hours ago* (last edited 8 hours ago) (1 children)
BallsFactory ballsFactory = new BallsFactory();
ballsFactory.setSuckable(true);
Balls balls = ballsFatctory.create();
[–] whats_all_this_then 4 points 3 hours ago* (last edited 3 hours ago) (1 children)

All of this is okay, but it's not production ready. This is what real production code looks like:

SuckableFactory suckableFactory = new SuckableFactory();
Suckable balls = suckableFactory
    .setShape(SuckableShapes.round)
    .setCount(2)
    .create();

SuctionProvider mouth = SuctionProvider.getInstance();

SuckerFactory suckerFactory = new SuckerFactory();
Sucker sucker = SuckerFactory.create():

sucker.setSuctionProvider(mouth);
sucker.setSuckable(balls);
sucker.setIntensity(SuckerSuctionIntensities.medium);
sucker.suckSuckable();
[–] whats_all_this_then 6 points 3 hours ago

Python port:

from ballsucker import suck
suck()
load more comments (2 replies)
load more comments (2 replies)
load more comments (2 replies)