DEV Community

Discussion on: Why bother using Polymorphism?

Collapse
 
bias profile image
Tobias Nickel

I think the initial code is the cleanest, because you don't care about environments at all. it is even more polymorphic. The initial code just Uploader.upload(avatar) vs Uploader.CreateByEnvironment().upload(avatar)

The upload function can hide the environment decision away just as good.

if it internally use use the different classes and CreateByEnvironment() does not matter.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
bias profile image
Tobias Nickel

Did you solved the chicken and egg problem, first there was the chicken factory builder constructor initializer configuration manager.

This might sound very mean, but i mean it. I thought about it. I do not even think this is necessary a bad thing. It is just a different way of working. My point is, if it is cheap to implement the amazon and google uploader in the firat place, then it will later also be cheap to change.

In this OOP world, you worry that you can not handle the uploader logic anymore, because it got to complex, and the solution is (and at this point I need your help to understand it right) to make it overly complex in the first place.

I thank you Valentin to enter this discussion, your points got me a bit further, but I worry to run into an impasse.

Collapse
 
chrisza4 profile image
Chakrit Likitkhajorn

Agree