this post was submitted on 14 Nov 2024
70 points (88.9% liked)

Programmer Humor

32565 readers
406 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] 12 points 1 week ago (2 children)

Balls.suck() is the correct syntax.

[–] [email protected] 5 points 1 week ago (2 children)

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

[–] [email protected] 9 points 1 week ago* (last edited 1 week ago) (1 children)
BallsFactory ballsFactory = new BallsFactory();
ballsFactory.setSuckable(true);
Balls balls = ballsFactory.create();
[–] [email protected] 9 points 1 week ago* (last edited 1 week 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();
[–] [email protected] 13 points 1 week ago

Python port:

from ballsucker import suck
suck()
[–] [email protected] 3 points 1 week ago

Or I didn't using the correct naming convention!

[–] luciferofastora 2 points 1 week ago

Actually, it would be OOP.suck(ddplf.getBalls())