Hellfire103 to Programmer Humor@lemmy.mlEnglish • 5 months agoTIFU by not using objects in my object-oriented programming courseworklemmy.caimagemessage-square24fedilinkarrow-up179arrow-down111cross-posted to: tifu@lemmy.world
arrow-up168arrow-down1imageTIFU by not using objects in my object-oriented programming courseworklemmy.caHellfire103 to Programmer Humor@lemmy.mlEnglish • 5 months agomessage-square24fedilinkcross-posted to: tifu@lemmy.world
minus-square@RagingToad@feddit.nllinkfedilink5•5 months agoDon’t you need to declare new Balls() first? Or do you suck() Balls static?
minus-squarexigoilinkfedilinkEnglish10•edit-25 months agoBallsFactory ballsFactory = new BallsFactory(); ballsFactory.setSuckable(true); Balls balls = ballsFactory.create();
minus-square@whats_all_this_then@lemmy.worldlinkfedilink11•edit-25 months agoAll 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();
minus-square@whats_all_this_then@lemmy.worldlinkfedilink14•5 months agoPython port: from ballsucker import suck suck()
minus-square@vext01@lemmy.sdf.orglinkfedilink3•5 months agoOr I didn’t using the correct naming convention!
Don’t you need to declare new Balls() first? Or do you suck() Balls static?
BallsFactory ballsFactory = new BallsFactory(); ballsFactory.setSuckable(true); Balls balls = ballsFactory.create();
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();
Python port:
from ballsucker import suck suck()
Or I didn’t using the correct naming convention!