TIFU by not using objects in my object-oriented programming coursework

2 years ago by Hellfire103 to c/programmerhumor

load all comments
ddplf -8 points 2 years ago

Good, OOP can suck my balls

path: 0 13457277, hotness: undefined, score: -8, children: 7
vext01 11 points 2 years ago

Balls.suck() is the correct syntax.

path: 0 13457277 13461257, hotness: undefined, score: 11, children: 6
RagingToad 4 points 2 years ago

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

path: 0 13457277 13461257 13461331, hotness: undefined, score: 4, children: 4
xigoi 8 points 2 years ago
BallsFactory ballsFactory = new BallsFactory();
ballsFactory.setSuckable(true);
Balls balls = ballsFactory.create();
path: 0 13457277 13461257 13461331 13462333, hotness: undefined, score: 8, children: 2
whats_all_this_then 11 points 2 years ago

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();
path: 0 13457277 13461257 13461331 13462333 13466861, hotness: undefined, score: 11, children: 1
whats_all_this_then 14 points 2 years ago

Python port:

from ballsucker import suck
suck()
path: 0 13457277 13461257 13461331 13462333 13466861 13466912, hotness: undefined, score: 14, children: 0
programmerhumor
programmerhumor

@lemmy.ml

login for more options
42540
1580
1384

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

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

go to feed...