this post was submitted on 14 Nov 2024
66 points (88.4% liked)

Programmer Humor

32483 readers
366 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
[–] vext01@lemmy.sdf.org 11 points 3 days ago (2 children)

Balls.suck() is the correct syntax.

[–] luciferofastora@lemmy.zip 2 points 3 days ago

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

[–] RagingToad@feddit.nl 4 points 3 days ago (2 children)

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

[–] xigoi@lemmy.sdf.org 8 points 3 days ago* (last edited 2 days ago) (1 children)
BallsFactory ballsFactory = new BallsFactory();
ballsFactory.setSuckable(true);
Balls balls = ballsFactory.create();
[–] whats_all_this_then@lemmy.world 9 points 3 days ago* (last edited 3 days 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@lemmy.world 13 points 3 days ago

Python port:

from ballsucker import suck
suck()
[–] vext01@lemmy.sdf.org 3 points 3 days ago

Or I didn't using the correct naming convention!