Type inference in Sakai code

2 views
Skip to first unread message

Adrian Fish

unread,
Oct 15, 2025, 12:10:08 PM (4 days ago) Oct 15
to sakai-dev
Hi all,

What are peoples opinions on using type inference in our codebase?
Since Java 10 (Sakai 22+) we've been able to use the var keyword to
declare a variable and assign it a value in one stroke, so:

var userName = new String("Bob");

This, I think, is less cluttered than using the old school:

String userName = new String("Bob");

We know it's a string already. However ...

var userName = api.getUserName();

... doesn't immediately tell you the type. You'd have to look at getUserName().

At the moment, we have our coderabbit rules setup to complain heavily
at the use of type inference.

What do you all think? Should we ban using type inference in our code?

Cheers,
Adrian.
Reply all
Reply to author
Forward
0 new messages