Davin Chia (Airbyte)
var
keyword in java? I’ve appreciated it more often than not when reading Java code. Charles seems fine. Curious to hear people’s thoughts before introducing it into the codebase.
• same question about final
. I see it being used pretty judiciously throughout but not applied entirely. is the expectation to use final as much as possible?
• can I confirm we line wrap at 150? (will update the docs)user
03/08/2021, 11:29 PMvar
. seems fine to use, but definitely not mandated.
• I think we prefer to have final any place the variable is intended to be final, but it isn’t generally mandated.
• Line wrap is 150, as seen in java-google-style.xml:376
user
03/08/2021, 11:38 PMvar
tu
i dislike final
in Java but am fine with its usage.
edit: maybe a hot take. TL;DR: it hurts readability and only prevents reassignment (which is nice but in my biased experience is rarely a problem), not immutability.user
03/08/2021, 11:44 PMuser
03/08/2021, 11:53 PMLine wrap is 150, as seen inah didn’t realise we checked in a code styles. should we update https://github.com/airbytehq/airbyte/blob/master/docs/contributing-to-airbyte/code-style.md#configure-java-style-for-intellij?java-google-style.xml:376
user
03/08/2021, 11:55 PMuser
03/09/2021, 12:00 AMfinal
’s lack of immutability reduces’s its helpfulness. imo any function where final
is somewhat useful is probably too long/complex. to me, it’s only useful in class variables, as many function might potentially access those, and preventing reassignment does simplify understanding
d. any function long enough thatuser
03/09/2021, 12:02 AMuser
03/09/2021, 12:02 AMuser
03/09/2021, 12:02 AMuser
03/09/2021, 2:10 AMvar
a shot for now.
• final
isn’t mandated
• I will update the docs on line length
• we should keep lombok
in mind for the futureuser
03/09/2021, 2:19 AMvar
on a previous team. I found adhering to https://openjdk.java.net/projects/amber/LVTIstyle.html was very helpful.
The general approach is to pair var
with other little changes that preserve the typo info without the verbosity. e.g. adding specific type into <>
with constructors, or within names, or using it in for
loops etc.
Of course, devs still retain the right to leave the type declaration if they think it’s useful!user
03/09/2021, 2:20 AM