Re: [DISCUSS] Usage of "var" instead of types in the code

2025-01-10 Thread Štefan Miklošovič
Ok let's keep it then. On Thu, Jan 9, 2025 at 10:26 PM Brandon Williams wrote: > I remain +1 to allow in tests. > > Kind Regards, > Brandon > > On Thu, Jan 9, 2025 at 3:20 PM David Capwell wrote: > > > > +1 to allow in tests > > > > On Jan 9, 2025, at 10:58 AM, Caleb Rackliffe > wrote: > > > >

Re: [DISCUSS] Usage of "var" instead of types in the code

2025-01-09 Thread Brandon Williams
I remain +1 to allow in tests. Kind Regards, Brandon On Thu, Jan 9, 2025 at 3:20 PM David Capwell wrote: > > +1 to allow in tests > > On Jan 9, 2025, at 10:58 AM, Caleb Rackliffe wrote: > > +1 to allowing in tests for now > > On Wed, Jan 8, 2025 at 12:51 PM Mick Semb Wever wrote: >> >> >> Jump

Re: [DISCUSS] Usage of "var" instead of types in the code

2025-01-09 Thread David Capwell
+1 to allow in tests > On Jan 9, 2025, at 10:58 AM, Caleb Rackliffe wrote: > > +1 to allowing in tests for now > > On Wed, Jan 8, 2025 at 12:51 PM Mick Semb Wever > wrote: >> >> Jumping in, I'm ok to allow it in tests for a trial period too. I would >> imagine in tes

Re: [DISCUSS] Usage of "var" instead of types in the code

2025-01-09 Thread Caleb Rackliffe
+1 to allowing in tests for now On Wed, Jan 8, 2025 at 12:51 PM Mick Semb Wever wrote: > > Jumping in, I'm ok to allow it in tests for a trial period too. I would > imagine in test methods especially it's of much less concern, where the > code is much simpler to read, and also safer to change t

Re: [DISCUSS] Usage of "var" instead of types in the code

2025-01-08 Thread Mick Semb Wever
Jumping in, I'm ok to allow it in tests for a trial period too. I would imagine in test methods especially it's of much less concern, where the code is much simpler to read, and also safer to change to types later on. On Wed, 8 Jan 2025 at 16:46, Josh McKenzie wrote: > I would like to remove th

Re: [DISCUSS] Usage of "var" instead of types in the code

2025-01-08 Thread Josh McKenzie
> I would like to remove this altogether from tests and ban it too in a week or > two. I took "ban it too in a week or two" as an indicator of intent. Looks like that's not what you intended. I believe at least David and I both use and would like to continue using "var" when working on tests. A

Re: [DISCUSS] Usage of "var" instead of types in the code

2025-01-08 Thread Štefan Miklošovič
Indeed, we don't. That's what "I would like to" means. I asked additional questions on 5th November wanting to know more about people advocating for vars in tests -> no response. I also do not see any vars added since then. So, what do we have vars enabled for? 1) not enough time has passed, me

Re: [DISCUSS] Usage of "var" instead of types in the code

2025-01-06 Thread Josh McKenzie
> I would like to remove this altogether from tests and ban it too in a week or > two. Don't think we had clear consensus here. On Sun, Jan 5, 2025, at 5:42 PM, Štefan Miklošovič wrote: > I would like to remove this altogether from tests and ban it too in a week or > two. > > I see that Bereng

Re: [DISCUSS] Usage of "var" instead of types in the code

2025-01-05 Thread Štefan Miklošovič
I would like to remove this altogether from tests and ban it too in a week or two. I see that Berenguer and Ariel are against that completely and Maxim as well. I was waiting for some time to see if the usage of this takes place so we do not ban that for people who might use that prematurely but

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-11-05 Thread Maxim Muzafarov
To me, this sounds like the style consistency throughout the project, so if we just allowed having the "var" keyword we would have a mix of new and old styles without any distant prospect of a unified style. We should evolve the code style from one unified form to another, thus either we use it ev

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-11-04 Thread Štefan Miklošovič
People who are OK with vars in tests - are you also the ones who are going to write vars from now on yourself or you just do not mind if you encounter it? There is a difference between "keep it in tests, I am going to use this, this is actually a good idea" and "keep it in tests if people are g

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-11-04 Thread Ariel Weisberg
Hi, I don’t like `var` anywhere. Even if IntelliJ could automatically insert the concrete type it would still be a problem in the GH compare view. GH compare view is a real problem, because any time something is sufficiently obfuscated I have to bounce back and forth with an IDE, check out the

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-31 Thread Berenguer Blasi
Nuke it out of orbit. -1 everywhere imo. I don't need another level of indirection and one more plate to spin while connecting dots in the code. On 30/10/24 17:47, Francisco Guerrero wrote: Yeah, I'm also in favor of disallowing usage of var in production code. On 2024/10/30 16:43:06 Jacek Lew

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-30 Thread Francisco Guerrero
Yeah, I'm also in favor of disallowing usage of var in production code. On 2024/10/30 16:43:06 Jacek Lewandowski wrote: > +1 for allow in tests and ban in production code. > > > > > - - -- --- - - > Jacek Lewandowski > > > śr., 30 paź 2024 o 17:37 David Capwell napi

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-30 Thread Jacek Lewandowski
+1 for allow in tests and ban in production code. - - -- --- - - Jacek Lewandowski śr., 30 paź 2024 o 17:37 David Capwell napisał(a): > I am fine with allow in tests ban in src > > On Oct 30, 2024, at 7:16 AM, Štefan Miklošovič > wrote: > > https://issues.apache.or

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-30 Thread David Capwell
I am fine with allow in tests ban in src > On Oct 30, 2024, at 7:16 AM, Štefan Miklošovič wrote: > > https://issues.apache.org/jira/browse/CASSANDRA-20038 > > On Wed, Oct 30, 2024 at 2:40 PM Brandon Williams > wrote: >> Allow in tests, forbid elsewhere is my vote and s

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-30 Thread Brandon Williams
Allow in tests, forbid elsewhere is my vote and simple to implement. Kind Regards, Brandon On Wed, Oct 30, 2024 at 6:46 AM Štefan Miklošovič wrote: > > against vars: > > Benjamin > Stefan > Benedict > Yifan > > somewhere in the middle: > > Dinesh > > Caleb +1 in tests and +0 in prod code. > Davi

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-30 Thread Štefan Miklošovič
https://issues.apache.org/jira/browse/CASSANDRA-20038 On Wed, Oct 30, 2024 at 2:40 PM Brandon Williams wrote: > Allow in tests, forbid elsewhere is my vote and simple to implement. > > Kind Regards, > Brandon > > On Wed, Oct 30, 2024 at 6:46 AM Štefan Miklošovič > wrote: > > > > against vars: >

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-30 Thread Aleksey Yeshchenko
Allow in tests, forbid elsewhere for now would be my vote. > On 30 Oct 2024, at 11:45, Štefan Miklošovič wrote: > > against vars: > > Benjamin > Stefan > Benedict > Yifan > > somewhere in the middle: > > Dinesh > > Caleb +1 in tests and +0 in prod code. > David - against flat out banning, li

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-30 Thread Štefan Miklošovič
against vars: Benjamin Stefan Benedict Yifan somewhere in the middle: Dinesh Caleb +1 in tests and +0 in prod code. David - against flat out banning, limiting it just for some places Josh prod / test on/off switch. for: Jon Correct me if I am wrong and I have "miscategorized" somebody. >Fr

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-30 Thread Benjamin Lerer
I recently faced some var usage in the CQL layer part where it was making the code pretty hard to understand. I am in favor of prohibiting it. Le mar. 29 oct. 2024 à 20:32, Caleb Rackliffe a écrit : > Josh's example of "good" usage seems defensible, because the declared type > is already obfusca

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Caleb Rackliffe
Josh's example of "good" usage seems defensible, because the declared type is already obfuscated to Collection anyway, and my eyeballs are going to skip to the right anyway to see the instantiated type. I'm +0 on prohibiting it in non-test code, and -1 on prohibiting it in tests. On Tue, Oct 29, 2

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Josh McKenzie
> how we are going to enforce that _at scale_ Without digging into our infrastructure, I'd assume rolling a check into our checkstyle targets would cover it. Have different for regular and test so could have two different rules. > Now, when I want to know type information my eyes have to jump al

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Yifan Cai
I am in favor of *disallowing* the `var` keyword. It does not provide a good readability, especially in the environments w/o type inference, e.g. text editor or github site. It could introduce performance degradation without being noticed. Consider the following code for example, Set allNames()

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Jon Haddad
When I first saw var as a Java keyword, my initial reaction was one of skepticism for the reasons already mentioned. However, in practice, I've been using var for years across many code bases (Java and Kotlin) and have never had an issue with readability. I find it to be significantly more pleasa

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Štefan Miklošovič
I get that there might be some situations when its usage does not pose any imminent problem but the question is how we are going to enforce that _at scale_? What is allowed and what not ... Sure we can have a code style for that, but its existence itself does not guarantee that everybody will adher

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Josh McKenzie
(sorry for the double-post) Jeremy Hanna kicked this link to a style guideline re: inference my way. Interesting read for those that are curious: https://openjdk.org/projects/amber/guides/lvti-style-guide On Tue, Oct 29, 2024, at 2:47 PM, Josh McKenzie wrote: > To illustrate my position from ab

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Benedict Elliott Smith
> Good usage: >> Collection names = new ArrayList<>(); > becomes >> var names = new ArrayList(); > This “good” usage quickly becomes bad, as you’re going to have to mix “good” and “bad” together, e.g.: >> var names1 = new ArrayList(); >> Collection names2 = myObject.getNames(); Now, when I

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Josh McKenzie
To illustrate my position from above: Good usage: > Collection names = new ArrayList<>(); becomes > var names = new ArrayList(); Bad usage: > Collection names = myObject.getNames(); becomes > var names = myObject.getNames(); Effectively, anything that's not clearly redundant in assignment should

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread David Capwell
I am one of the people using var, and this mostly comes from me doing “int” and having IntelliJ fix it (faster than typing out Future>>>)… so its a faster version for me… Personally I find that while I am writing the code I like var, but as I hone it I tend to remove it to improve readability.

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Dinesh Joshi
I lean on the side of being explicit but I want to recognize that there are exceptions to every rule. There are situations where it might be acceptable to use var and may help productivity. We should enumerate it in our code style / developer docs. I think it is ok to use var in scripts or test cas

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Štefan Miklošovič
Yes, for now it is pretty much just in SAI. I wanted to know if this is a thing from now on or where we are at with that ... I am afraid that if we don't make this "right" then we will end up with a codebase with inconsistent usage of that and it will be even worse to navigate in it in the long te

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Brandon Williams
On Tue, Oct 29, 2024 at 12:15 PM Štefan Miklošovič wrote: > I think this is a new concept here which was introduced recently with support > of Java 11 / Java 17 after we dropped 8. To put a finer point on that, 4.1 has 3 hits, none of which are valid, while 5.0 has 172. If 'sai' is added to the

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Benedict Elliott Smith
I’m glad you brought this up Stefan, I’d been meaning to raise this myself. var is valuable for hacking and scripting, but I think it is counterproductive for a codebase like ours, that is mostly read not written, and where this keyword creates inconsistencies in where information for navigating

Re: [DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Josh McKenzie
Not having type inference has made me grumpy about working on our codebase vs. tinkering in C# for the past decade. So you can guess where I stand on that. :) I'm all for us adopting it in scenarios where the type of an object is immediately obvious (i.e. doesn't require navigation to a method o

[DISCUSS] Usage of "var" instead of types in the code

2024-10-29 Thread Štefan Miklošovič
Hello, this should give you an idea grep --include '*.java' -r 'var ' src/ test/ I think this is a new concept here which was introduced recently with support of Java 11 / Java 17 after we dropped 8. What is your opinion? Are we free to use it wherever we want? I am quite conservative in this