code style questions as I read more code: - how do...
# contributing-to-airbyte
d
code style questions as I read more code: • how do people feel about using the 
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)
u
• No opinion on
var
. 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
u
var
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.
u
https://projectlombok.org/features/val I’d love to have something like this but the java committee decided against it. Maybe Lombok would be a valuable add to the codebase.
u
Line wrap is 150, as seen in 
java-google-style.xml:376
ah 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?
u
@Davin Chia (Airbyte) yeah
u
Sherif, agree with ya
final
’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 that
u
fwiw, i'm not a big fan of var. i like being able to read the types. when you're working in an IDE it doesn't matter too much, but it makes code review harder because I am a human and not an ide (for better or for worse 🤷‍♀️ )
u
Lombok is neat - haven’t used it before, so no opinion on how it’s like. Not opposed to giving it a shot
u
i do not care enough if other folks like var though. i will endeavor to be more like an ide.
u
in conclusion, • we’ll give
var
a shot for now. •
final
isn’t mandated • I will update the docs on line length • we should keep
lombok
in mind for the future
u
Charles, I had the same reservations when we initially tried out
var
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!
u
I’ll make a note to follow up at a later date to see how people feel 🙂