3
Awlex
5y

Today I found a faulty design choice in java, that seriously makes me hate java. Basically java prohibits abstract static methods. This -combined with the poor design choices for constructors - means that Subclasses cannot have a common constructor or static method calling the constructor.

Basically meaning that you can't just map a collection to objects without handling EVERY FUCKING CASE, WRITING THE WHOLE MAPPING AGAIN AND AGAIN, ADDING A FORCED PORTION OF SPAGHETTI WITH EVERY CLASS WHERE THIS WAS NEEDED.
https://stackoverflow.com/questions...

There seem to be other OOP languages with this faulty design. Can't say if I now hate OOP ingeneral or not, because maybe some languages may have provided a substitute for this

Comments
  • 1
    The very first reply explains why abstract and static are oximorons.

    Static method wont call the constructor, thats pretty much the point of being static, that they dont need a serialized object.

    "Subclasses cant have a common constructor" uh what? You know super() exists right?

    You want to map a collection of what exactly to objects?

    To me it seems it aint java thats stupid huh
  • 0
    I don't understand why anyone would ever need this... But I do know that you can provide default implementation in super classes.
  • 0
    @ganjaman
    And one of the comments points out, why that's BS.

    If I want to return an object from that particular class, I'll have to call it's constructor eventually.

    I know what super(), is. I probably worded that wrong. I meant common constructor as in accepts has common arguments, but does different under the hood. Essentially MAPPING the contents of argument to either perhaps another constructor.

    For the collections, just imagine a (stupidly) deep nested api
  • 0
    Oh you mean you need a big jsonobject? Gson does that really well.
  • 0
    If I’m not mistaken, Swift actually supports overrideable class methods that can be invoked by use of a dynamic call at runtime.
  • 0
    What exactly are you trying to?
Add Comment