Piston Piston1 = CarFactory().makeCar("Car", 4).getEngine().getCylinders().get(2).getPiston();

Piston Piston1 = CarFactory().makeCar("Car", 4).getEngine().getCylinders().get(2).getPiston();

Attached: images.png (430x342, 10K)

if u have piston class can't you just get it from there?

yeah but that piston does not belong to any instance of Cylinder that is in an instance of Engine that is in an instance of Car.

china.getFactory().produceProduct("piston").await().transportTo(myLocation).await()

>not using a singleton factory
>not using Java coding conventions
>not wrapping your primitive types
Piston piston = CarFactory.getInstance().make(new String("Car"), new Integer(4)).getEngine().getCylinders().get(new Integer(2)).getPiston();

Piston piston = getPiston(&getCylinder(&getCylinders(&getEngine(&makeCar(&carfactory, "Car", 4))), 2));

If you want something that specific then you have write something specific. Why are you surprised that your autistic specifications result in autistic code?

Attached: 1507428132684.png (586x578, 37K)

OOP is so fucking gay

>Cylinder that is in an instance of Engine that is in an instance of Car
why
is an engine a car with modifications?
in the same way, can I say this 2200uF capacitor is a computer with modifications?

>he needs to access a subsubsubsub field in a higher order function
What's the point of constructing a car just to extract a piston from it?

Attached: 20180319_131054_edited.png (1320x1405, 1.05M)

he wanted a piston but the constructor was protected

Protected classes are supposed to be abstracted away. Either OP is using the library wrong or the library is trash.

>singleton
I haven't used "classical" OOP in nearly a decade. When did singleton stopped being considered an anti-pattern?

And you lose reference to Car instance you fucking retard

so what would a car look like if modeled functionally?

(get-piston (get (get-cylinders (get-engine (make-car "Car" 4) ) ) 2 ))

It never was an anti-pattern. I mean it was to morons who don't understand basics of OOP and instead introduce all sorts of service locators and DI containers which are in fact thinly-veiled singletons. The irony.

(make-instance 'car)

(make-instance 'cylinder)

That sounds more like you being a retard than a problem with Java

I won't stop posting here until the entirety of Jow Forums laments OOP.

I remember watching one of Google's "clean code" talks years ago where a guy argued singleton is just a convoluted way of introducing global state and unnecessary coupling, and if you want a single instance of a class, you should just create one instance and pass it around instead of relying on hard-to-unit-test "clever" static call fuckery GoF singleton is.

Some people actually think a programming language should not allow you to do dumb things

>max speed as attribute

Max speed is a function of rolling resistance, gearing and torque

What kind of retard made that image?

Rolling resistance is a function of friction and surface. Surface is a function of geometry. Friction is a function of material, temperature and microscopic surface. Temperature is a function of internal energy and entropy. Internal energy is a function of kinetic and potential energy at the microscopic level. Entropy is a function of momentum at the microscopic level.

What kind of retard made that post?

You're doing it wrong

Spherical cows etc

how does drive() method work ?
it's a german car, so it's electronically limited

>be OP
>looking for a piston for my project
>guess I’ll make a car then
>rip the engine out of the car
>rip the cylinder out of the engine
>rip the piston out of the cylinder
>use the piston
>thrash everything else

Nice software engineering, retard

car.getApi().sendMessage(wheels, "car.wheels");

Attached: 1511975879811.png (949x647, 26K)

kek and /thread

Attached: kek.gif (220x211, 35K)

Car car = new Car();

Have a getter for every part of the car to make shit easier?

That's some next level strawmanning user.

std::shared_ptr car = std::make_shared()

auto car = Car::factory.makeCar();
heh

that's literally what the code is doing, brainlet

Attached: 1523175065656.jpg (960x960, 75K)

>having to make a car to get a piston in the first place
kys

>Looking for a piston
He needs a piston from the specific car he just created.
>Piston x = new Piston(...)
It's not really necessary to make a car first. I mean OP is still a retard for not having a method that gets the piston straight from the Car class but come on now.

>He needs a piston from the specific car he just created.
[citation needed]

do you understand what a "getter" function is you fucking retard?
you just backtracked over your initial post
jesus christ do you have brain damage?

What's stopping him from doing Piston x = new Piston()? Pretty sure he wouldn't go through the trouble of making a car beforehand just to make a random piston. Or maybe he is and OP is an even bigger retard than I thought.
I do, and that's exactly what he needs. A function to get the piston straight from Car and not having to go through every other "car part".

often, when you see bullshit like this, something happens to the piston when the car is made
you could (and possibly even should) just figure out what happens to the piston when making the car instead of making a whole car just to get the side-effects the process has on the piston

if you're doing this for code de-duplication, refactor that bit with the process to make that sort of piston since it's clearly useful in multiple places

>Car depends on Engine
>Engine depends on multiple instances of Cylinder
>Cylinder depends on multiple instances of Piston
>Car should expose a method to get "the piston" directly, because that's how cars work in real life, plus having a bazillion methods for every single object in the entire dependency graph is a great fucking design

I don't know C++.
Is shared_ptr shared memory?

>I do
no you clearly do not you incessant faggot
a getter function belongs to a class and returns an attribute of that class
if you're claiming he needs a getter function to get the Piston, the Piston must be an attribute of a class (namely Car) and the getter function must be called from an object of the Car class

holy FUCKING shit jump off a cliff you absolute mollusk

>Piston x = new Piston()
to FURTHER shit on your absolute faggotry, what you've written is a call to a constructor function, which instantiates a new object of a class; this is NOT a getter function
holy fucking christ you don't even understand the fundamental language of OOP and you're acting like you can give advice on the topic please tie a noose around your useless neck and take a quick drop

Attached: 7dc45c647fecf9f312395a07c22babd52752dfaf.gif (468x60, 23K)

somePiston :: Piston
somePiston = piston . (!! 2) . cylinders . engine $ someCarConstructor "Car" 4

It could be (much) better but I can't into Lenses. Actually as long as your data structure is just a bunch of independent data fields that you want to extract (records) it's not that much different. It is pretty different when it turns out your data can be represented by a function or when it's an alternative of things (technically a sum).

> slc

while(crFctry[0] > 0 && crFctry[0]) {
if(crFctry[1] > 0 && crFctry[1]

Car car = New Car (sedan, v6, AWD);
Piston piston = car.getPiston(1);
Woooooaaaahhhhhhhhh so hard

If not secure & in a loop, forget it. Don't even write functions, let ai do it.

Dragonfly on Java.jpg

Car shouldn't be aware of or care about the inner workings of its engine, though. It should be able to work with an instance of PureFuckingMagicEngine that has no pistons at all.

Not my cars :) they can have a v2-v24 or an inline1-8 engine and that's it

type Piston struct{}

func (p *Piston) Combust(f Fuel) {}

type Engine Interface{
Combust(Fuel)
}

:^)

What if your instance of car is a Tesla? There is no piston to get.

No faggot teslas allowed

It's a "smart pointer", which wraps a raw C++ pointer, and automatically deletes the object it points to when it's deleted. A shared_ptr, in contrast to a unique_ptr, can be copied. It doesn't destroy the object until the last copy of the pointer is destroyed.

>it's an OP does a retarded thing in OOP that doesn't even adhere to the specs
Why do these threads ALWAYS get tons of replies?

Friction is a function of normal force you faggot this post is gay and you're gay

>piston is an object
>not an attribute of car
i would laugh if it weren't so pathetic :^(

Car c = new Car();
System.out.println(c.piston);

:^)

>not using a getter

>using a getter

>Frankenstein encapsulation