I love this. This is a perfect exemplar of the absurdities of code, from the nonsensical boilerplate overhead of OOP styles to utter ennui.https://twitter.com/16kbps/status/912319298684772352 …
You can add location information to your Tweets, such as your city or precise location, from the web and via third-party applications. You always have the option to delete your Tweet location history. Learn more
It's 4x more loc than it needs to be and couples the class to whatever's constructing it.
Is this dependency injection?
What's the difference (I thought dep injection was "passing in values for member vars as part of the constructor")?
That's one (weak) way to accomplish it. In this case, it's irrelevant as the int type is a platform type and DI is unnecessary.
But more generally Dependency Injection's benefit is to accomplish inversion of control. So it's the control paradigm that matters.
IoC basically means "don't `new` off classes," and one way to accomplish this is to provide a reference to the object that needs that class
That's standard boilerplate Java
This is how you implement dependency inversion tho...?
Not necessarily. There are other, better ways.
ok, what do you prefer?
My favorite antipattern ever. "As a rule, let's create getters and setters for every private var ever" - basically every bad CS prof ever
My problem with not using the same name for the constructor/member variable is that you have to come up variable names like initMyVar
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.