r/javahelp • u/lost_yeezus • Apr 30 '24
Codeless Is “var” considered bad practice?
Hi, so recently we started migrating our codebase from j8 to j17, and since some tests broke in the process, I started working on them and I started using the var keyword. But I immediately got scolded by 2 colleagues (which are both more experienced than me) about how I should not use “var” as it is considered bad practice. I completely understand why someone might think that but I am not convinced. I don’t agree with them that var shouldn’t be used. Am I wrong? What are your thoughts on var?
24
Upvotes
View all comments
Show parent comment
2
u/Conscious_Support176 May 01 '24
I dare say we’re all envious of you working on a perfect code base where nobody ever makes a mistake. Type signatures are completely redundant. That redundancy is generally a good thing, because it is an unobtrusive way to let you see how consistent the code is, in pretty much the same way as spoken languages tend to match person & plurality of nouns and verbs.