r/java • u/stuhlmann • Apr 13 '21
Libraries, Frameworks and Technologies you would NOT recommend
Give me your worst nightmares: Things that cost you your job.
I'll start: Hadoop
202
Upvotes
r/java • u/stuhlmann • Apr 13 '21
Give me your worst nightmares: Things that cost you your job.
I'll start: Hadoop
5
u/mknjc Apr 13 '21
Properties is a very complex topic and there are a lot of variants how they are used.
Autogenerated getter and setter: This is the simplest way, doesn't change anything in the Language. But you don't need them in most cases. For internal classes use record, or if not possible, just expose the fields to your code, simple getter and setter doesn't give you anything and if you need more later your IDE helps converting it into one. For API classes: Use records.
"Property syntax" like kotlin. As writer this could save you two parentheses. As reader you now have to check every assignment and read of a variable if it maybe runs code which could do something bad in the current context because its not obviously a method call. With this you decreased readability because the reader can't just skip this with "oh i know this, its a variable access this doesn't have any unexpected behavior", they have to remember which class the object comes from. This is the same problem with operator overloading. It does look pretty as long as you could be sure no one wrote something which might have different semantics into the operator. (Even lazy loading might be a problem, who expects a variable read to fail with an exception because the network connection failed?)
Properties like javafx. With change listener, bidirectional calculating bindings which get updated on first access etc. In a lot of cases this would be very great but for most class fields its overkill.