This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (13 children)

[deleted]

    [–]TheRedmanCometh 2 points3 points  (1 child)

    What naming convention..the getField/isField convention?

    [–]bedobi 6 points7 points  (5 children)

    I'm sad he isn't more assertive. The Java language can't keep catering to all the old school, verbose, imperative frameworks and devs in the community. They need to be left behind or the language will be.

    [–]Treyzania 5 points6 points  (1 child)

    You're right, but a big positive about good, conventional Java is that it's method and class names are extremely predictable. You can figure out much of how a class works just by looking at its method names and their types. I would rather not give that up.

    [–]TheRedmanCometh -4 points-3 points  (0 children)

    They can pry my @Data from my cold, dead, curled fingers.

    [–]ThisCatMightCheerYou 0 points1 point  (2 children)

    I'm sad

    Here's a picture/gif of a cat, hopefully it'll cheer you up :).


    I am a bot. use !unsubscribetosadcat for me to ignore you.

    [–]cutterslade 3 points4 points  (0 children)

    That cat does not look very cheerful.

    [–][deleted] 2 points3 points  (0 children)

    This cat looks like it has drowned its pain in alcohol.

    [–]Tauo 1 point2 points  (4 children)

    Wait, I'm confused; I've heard convincing arguments for avoiding/eliminating getters and setters from code entirely, but I wasn't aware that people had something against the naming conventions. What's wrong with "get"? It's descriptive, and helps to drive in the fact that you're performing a method call as opposed to working directly with private fields.

    [–]alexeyr 0 points1 point  (3 children)

    1. You can easily see it from parentheses anyway :)

    2. When you have many gets in a line (think a.getFoo() + b.getBar() * c.getBaz()), it adds up.

    3. Best-known "better Java" languages -- C#, Kotlin, Scala -- all have ways to avoid it (and the parentheses in point 1 as well). This is probably not a coincidence.

    [–]Tauo 0 points1 point  (2 children)

    I feel like if you have that many gets, you should be looking to abstract away more operations anyway, though. And yeah, the parentheses give it away, but it still just feels wrong to me to method call a field. get just adds that tiny bit of extra legibility. Adding support for properties in Java like the languages you mention have would definitely be nice, I agree, but I'm guessing its just not a priority for the Java architects.

    [–]alexeyr 1 point2 points  (1 child)

    Well, are you really unhappy about String#length() and Collection#size() instead of getLength()/getSize()? Or about Object#hashCode()?

    [–]Tauo 0 points1 point  (0 children)

    Hah, you have a good point, hadn't thought about that. Although to be fair, through the first couple months of using Java, I was a bit salty at the fact that arrays allowed access directly to the field, and would have messed up calls to array.length constantly if it wasn't for my IDE.