You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cassandra.apache.org by Alex Petrov <al...@coffeenco.de> on 2022/06/03 13:52:41 UTC
[DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Hi everyone,
In our style guide [1], we have a following statement:
> Avoid redundant `@Override` annotations when implementing abstract or interface methods.
I'd like to suggest we change this.
@Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
Thank you,
--Alex
[1] https://cassandra.apache.org/_/development/code_style.html
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Stefan Miklosovic <st...@instaclustr.com>.
Hi,
I was living with the fact that we are putting @Override in the cases
you described already. I _think_ it was David Capwell (sorry if I am
wrong here) who suggested we should start to put @Override on these
methods but it was a very long time ago. I'll try to go over the ML
archive to find it. There was definitely a discussion about @Override
specifically.
Regards
On Fri, 3 Jun 2022 at 15:53, Alex Petrov <al...@coffeenco.de> wrote:
>
> Hi everyone,
>
> In our style guide [1], we have a following statement:
>
> > Avoid redundant @Override annotations when implementing abstract or interface methods.
>
> I'd like to suggest we change this.
>
> @Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
>
> I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
>
> More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
>
> The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
>
> Thank you,
> --Alex
>
> [1] https://cassandra.apache.org/_/development/code_style.html
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Stefan Miklosovic <st...@instaclustr.com>.
https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
On Fri, 3 Jun 2022 at 16:11, Derek Chen-Becker <de...@chen-becker.org> wrote:
>
> I think we discussed this a couple of weeks ago, but to reiterate my position: I think we should use annotations where they allow the compiler and ancillary tooling (e.g. FindBugs) to catch and prevent classes of errors. @Override seems like a pretty easy one to add, and has concrete examples of the kinds of errors it can prevent. We discussed @Nullable, @Threadsafe and others that may have more marginal utility, so we were a bit less prescriptive there. To sum up, I agree with Alex that @Override has enough utility to say we should use it by default.
>
> Cheers,
>
> Derek
>
> On Fri, Jun 3, 2022 at 8:04 AM Dinesh Joshi <dj...@apache.org> wrote:
>>
>> So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
>>
>>
>> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>>
>>
>> Hi everyone,
>>
>> In our style guide [1], we have a following statement:
>>
>> > Avoid redundant @Override annotations when implementing abstract or interface methods.
>>
>> I'd like to suggest we change this.
>>
>> @Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
>>
>> I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
>>
>> More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
>>
>> The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
>>
>> Thank you,
>> --Alex
>>
>> [1] https://cassandra.apache.org/_/development/code_style.html
>
>
>
> --
> +---------------------------------------------------------------+
> | Derek Chen-Becker |
> | GPG Key available at https://keybase.io/dchenbecker and |
> | https://pgp.mit.edu/pks/lookup?search=derek%40chen-becker.org |
> | Fngrprnt: EB8A 6480 F0A3 C8EB C1E7 7F42 AFC5 AFEE 96E4 6ACC |
> +---------------------------------------------------------------+
>
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Derek Chen-Becker <de...@chen-becker.org>.
I think we discussed this a couple of weeks ago, but to reiterate my
position: I think we should use annotations where they allow the compiler
and ancillary tooling (e.g. FindBugs) to catch and prevent classes of
errors. @Override seems like a pretty easy one to add, and has concrete
examples of the kinds of errors it can prevent. We discussed @Nullable,
@Threadsafe and others that may have more marginal utility, so we were a
bit less prescriptive there. To sum up, I agree with Alex that @Override
has enough utility to say we should use it by default.
Cheers,
Derek
On Fri, Jun 3, 2022 at 8:04 AM Dinesh Joshi <dj...@apache.org> wrote:
> So your proposal is to always add override annotation? Or are there
> situations where you don’t want to add them?
>
>
> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>
>
> Hi everyone,
>
> In our style guide [1], we have a following statement:
>
> > Avoid redundant @Override annotations when implementing abstract or
> interface methods.
>
> I'd like to suggest we change this.
>
> @Override annotation in subclasses might be annoying when you're writing
> the code for the first time, or reading already familiar code, but when
> you're working on large changes and have complex class hierarchies, or
> multiple overloads for the method, it's easy to overlook methods that were
> not marked as overrides, and leave a wrong method in the code, or
> misinterpret the call chain.
>
> I think @Override annotations are extremely useful and serve their
> purpose, especially when refactoring: I can change the interface, and will
> not only be pointed to all classes that do not implement the new version
> (which compiler will do anyways), but also will be pointed to the classes
> that, to the human eye, may look like they're overriding the method, but in
> fact they do not.
>
> More concrete example: there is an abstract class between the interface
> and a concrete implementation: you change the interface, modify the method
> in the abstract class, but then forget to change the signature in the
> overriden implementation of the concrete class, and get a behaviour from
> the abstract class rather then concrete implementation.
>
> The question is not about taste or code aesthetics, but about making
> maintaining a large codebase that has a lot of complexity and that was
> evolving over many years simpler. If you could provide an example where
> @Override would be counter-productive or overly burdensome, we could
> compare this cost of maintenance with the cost of potential errors.
>
> Thank you,
> --Alex
>
> [1] https://cassandra.apache.org/_/development/code_style.html
>
>
--
+---------------------------------------------------------------+
| Derek Chen-Becker |
| GPG Key available at https://keybase.io/dchenbecker and |
| https://pgp.mit.edu/pks/lookup?search=derek%40chen-becker.org |
| Fngrprnt: EB8A 6480 F0A3 C8EB C1E7 7F42 AFC5 AFEE 96E4 6ACC |
+---------------------------------------------------------------+
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by "benedict@apache.org" <be...@apache.org>.
I’ve opened a PR: https://github.com/apache/cassandra-website/pull/137
Not sure what our commit norms are for the website, but I’m assuming we would normally expect a +1 from somebody else.
From: Dinesh Joshi <dj...@apache.org>
Date: Saturday, 4 June 2022 at 19:59
To: dev@cassandra.apache.org <de...@cassandra.apache.org>
Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
sounds good. Lazy consensus it is.
On Jun 4, 2022, at 11:09 AM, benedict@apache.org wrote:
I think lazy consensus is good enough here, since there has been no dissent so far as I can tell. It’s easier to modify if we assume lazy consensus until a dispute arises. If anyone wants to escalate to a formal vote, feel free to say so.
I’ll update the wiki in a couple of days; we can always roll back if a dissenting voice appears.
From: Dinesh Joshi <dj...@apache.org>
Date: Friday, 3 June 2022 at 18:34
To: dev@cassandra.apache.org <de...@cassandra.apache.org>
Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Let’s bring it to vote? We can update the docs as we evolve the guidance but I think it’s in a good enough shape to publish.
On Jun 3, 2022, at 9:07 AM, benedict@apache.org wrote:
I always ask if we’re ready, get a few acks, then one or two new queries come out of the woodwork.
Perhaps I will just publish, and we can start addressing these queries in a follow-up process.
From: Dinesh Joshi <dj...@apache.org>
Date: Friday, 3 June 2022 at 16:57
To: dev@cassandra.apache.org <de...@cassandra.apache.org>
Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
I don’t think the guide has yet been published to the official website, has it? Maybe we should just get it out there.
On Jun 3, 2022, at 8:54 AM, benedict@apache.org wrote:
Somebody hasn’t looked at the new style guide*, the conversation for which keeps rolling on and so it never quite gets promoted to the wiki. It says:
Always use @Override annotations when implementing abstract or interface methods or overriding a parent method.
* https://docs.google.com/document/d/1sjw0crb0clQin2tMgZLt_ob4hYfLJYaU4lRX722htTo
From: Josh McKenzie <jm...@apache.org>
Date: Friday, 3 June 2022 at 16:14
To: dev@cassandra.apache.org <de...@cassandra.apache.org>
Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
> Avoid redundant @Override annotations when implementing abstract or interface methods.
I'd argue they're not redundant. We're humans and infinitely fallible. :)
+1 to changing this to just always annotate for all the reasons you enumerate.
On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
Right, my thinking matches what David has mentioned:
https://issues.apache.org/jira/browse/CASSANDRA-16096
https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
I'll make sure to update the style guide itself, too, since it looks like there was a vote, and intellij file is updated, just need to fixup the website.
On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
Hi everyone,
In our style guide [1], we have a following statement:
> Avoid redundant @Override annotations when implementing abstract or interface methods.
I'd like to suggest we change this.
@Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
Thank you,
--Alex
[1] https://cassandra.apache.org/_/development/code_style.html
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Dinesh Joshi <dj...@apache.org>.
sounds good. Lazy consensus it is.
> On Jun 4, 2022, at 11:09 AM, benedict@apache.org wrote:
>
>
> I think lazy consensus is good enough here, since there has been no dissent so far as I can tell. It’s easier to modify if we assume lazy consensus until a dispute arises. If anyone wants to escalate to a formal vote, feel free to say so.
>
> I’ll update the wiki in a couple of days; we can always roll back if a dissenting voice appears.
>
>
> From: Dinesh Joshi <dj...@apache.org>
> Date: Friday, 3 June 2022 at 18:34
> To: dev@cassandra.apache.org <de...@cassandra.apache.org>
> Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
>
> Let’s bring it to vote? We can update the docs as we evolve the guidance but I think it’s in a good enough shape to publish.
>
>
> On Jun 3, 2022, at 9:07 AM, benedict@apache.org wrote:
>
>
> I always ask if we’re ready, get a few acks, then one or two new queries come out of the woodwork.
>
> Perhaps I will just publish, and we can start addressing these queries in a follow-up process.
>
> From: Dinesh Joshi <dj...@apache.org>
> Date: Friday, 3 June 2022 at 16:57
> To: dev@cassandra.apache.org <de...@cassandra.apache.org>
> Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
>
> I don’t think the guide has yet been published to the official website, has it? Maybe we should just get it out there.
>
> On Jun 3, 2022, at 8:54 AM, benedict@apache.org wrote:
>
>
> Somebody hasn’t looked at the new style guide*, the conversation for which keeps rolling on and so it never quite gets promoted to the wiki. It says:
>
> Always use @Override annotations when implementing abstract or interface methods or overriding a parent method.
>
> * https://docs.google.com/document/d/1sjw0crb0clQin2tMgZLt_ob4hYfLJYaU4lRX722htTo
>
>
> From: Josh McKenzie <jm...@apache.org>
> Date: Friday, 3 June 2022 at 16:14
> To: dev@cassandra.apache.org <de...@cassandra.apache.org>
> Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
>
> > Avoid redundant @Override annotations when implementing abstract or interface methods.
> I'd argue they're not redundant. We're humans and infinitely fallible. :)
>
> +1 to changing this to just always annotate for all the reasons you enumerate.
>
> On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
> Right, my thinking matches what David has mentioned:
>
> https://issues.apache.org/jira/browse/CASSANDRA-16096
> https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
>
> I'll make sure to update the style guide itself, too, since it looks like there was a vote, and intellij file is updated, just need to fixup the website.
>
>
> On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
> So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
>
>
> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>
> Hi everyone,
>
> In our style guide [1], we have a following statement:
>
> > Avoid redundant @Override annotations when implementing abstract or interface methods.
>
> I'd like to suggest we change this.
>
> @Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
>
> I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
>
> More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
>
> The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
>
> Thank you,
> --Alex
>
> [1] https://cassandra.apache.org/_/development/code_style.html
>
>
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by "benedict@apache.org" <be...@apache.org>.
I think lazy consensus is good enough here, since there has been no dissent so far as I can tell. It’s easier to modify if we assume lazy consensus until a dispute arises. If anyone wants to escalate to a formal vote, feel free to say so.
I’ll update the wiki in a couple of days; we can always roll back if a dissenting voice appears.
From: Dinesh Joshi <dj...@apache.org>
Date: Friday, 3 June 2022 at 18:34
To: dev@cassandra.apache.org <de...@cassandra.apache.org>
Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Let’s bring it to vote? We can update the docs as we evolve the guidance but I think it’s in a good enough shape to publish.
On Jun 3, 2022, at 9:07 AM, benedict@apache.org wrote:
I always ask if we’re ready, get a few acks, then one or two new queries come out of the woodwork.
Perhaps I will just publish, and we can start addressing these queries in a follow-up process.
From: Dinesh Joshi <dj...@apache.org>
Date: Friday, 3 June 2022 at 16:57
To: dev@cassandra.apache.org <de...@cassandra.apache.org>
Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
I don’t think the guide has yet been published to the official website, has it? Maybe we should just get it out there.
On Jun 3, 2022, at 8:54 AM, benedict@apache.org wrote:
Somebody hasn’t looked at the new style guide*, the conversation for which keeps rolling on and so it never quite gets promoted to the wiki. It says:
Always use @Override annotations when implementing abstract or interface methods or overriding a parent method.
* https://docs.google.com/document/d/1sjw0crb0clQin2tMgZLt_ob4hYfLJYaU4lRX722htTo
From: Josh McKenzie <jm...@apache.org>
Date: Friday, 3 June 2022 at 16:14
To: dev@cassandra.apache.org <de...@cassandra.apache.org>
Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
> Avoid redundant @Override annotations when implementing abstract or interface methods.
I'd argue they're not redundant. We're humans and infinitely fallible. :)
+1 to changing this to just always annotate for all the reasons you enumerate.
On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
Right, my thinking matches what David has mentioned:
https://issues.apache.org/jira/browse/CASSANDRA-16096
https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
I'll make sure to update the style guide itself, too, since it looks like there was a vote, and intellij file is updated, just need to fixup the website.
On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
Hi everyone,
In our style guide [1], we have a following statement:
> Avoid redundant @Override annotations when implementing abstract or interface methods.
I'd like to suggest we change this.
@Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
Thank you,
--Alex
[1] https://cassandra.apache.org/_/development/code_style.html
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Dinesh Joshi <dj...@apache.org>.
Let’s bring it to vote? We can update the docs as we evolve the guidance but I think it’s in a good enough shape to publish.
>
> On Jun 3, 2022, at 9:07 AM, benedict@apache.org wrote:
>
>
> I always ask if we’re ready, get a few acks, then one or two new queries come out of the woodwork.
>
> Perhaps I will just publish, and we can start addressing these queries in a follow-up process.
>
> From: Dinesh Joshi <dj...@apache.org>
> Date: Friday, 3 June 2022 at 16:57
> To: dev@cassandra.apache.org <de...@cassandra.apache.org>
> Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
>
> I don’t think the guide has yet been published to the official website, has it? Maybe we should just get it out there.
>
> On Jun 3, 2022, at 8:54 AM, benedict@apache.org wrote:
>
>
> Somebody hasn’t looked at the new style guide*, the conversation for which keeps rolling on and so it never quite gets promoted to the wiki. It says:
>
> Always use @Override annotations when implementing abstract or interface methods or overriding a parent method.
>
> * https://docs.google.com/document/d/1sjw0crb0clQin2tMgZLt_ob4hYfLJYaU4lRX722htTo
>
>
> From: Josh McKenzie <jm...@apache.org>
> Date: Friday, 3 June 2022 at 16:14
> To: dev@cassandra.apache.org <de...@cassandra.apache.org>
> Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
>
> > Avoid redundant @Override annotations when implementing abstract or interface methods.
> I'd argue they're not redundant. We're humans and infinitely fallible. :)
>
> +1 to changing this to just always annotate for all the reasons you enumerate.
>
> On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
> Right, my thinking matches what David has mentioned:
>
> https://issues.apache.org/jira/browse/CASSANDRA-16096
> https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
>
> I'll make sure to update the style guide itself, too, since it looks like there was a vote, and intellij file is updated, just need to fixup the website.
>
>
> On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
> So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
>
>
> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>
> Hi everyone,
>
> In our style guide [1], we have a following statement:
>
> > Avoid redundant @Override annotations when implementing abstract or interface methods.
>
> I'd like to suggest we change this.
>
> @Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
>
> I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
>
> More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
>
> The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
>
> Thank you,
> --Alex
>
> [1] https://cassandra.apache.org/_/development/code_style.html
>
>
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Ekaterina Dimitrova <e....@gmail.com>.
+1
On Fri, 3 Jun 2022 at 12:26, Derek Chen-Becker <de...@chen-becker.org>
wrote:
> +1 to publishing. We should consider it a living document, not something
> that we need to necessarily set in stone :)
>
> Cheers,
>
> Derek
>
> On Fri, Jun 3, 2022 at 10:05 AM benedict@apache.org <be...@apache.org>
> wrote:
>
>> I always ask if we’re ready, get a few acks, then one or two new queries
>> come out of the woodwork.
>>
>>
>>
>> Perhaps I will just publish, and we can start addressing these queries in
>> a follow-up process.
>>
>>
>>
>> *From: *Dinesh Joshi <dj...@apache.org>
>> *Date: *Friday, 3 June 2022 at 16:57
>> *To: *dev@cassandra.apache.org <de...@cassandra.apache.org>
>> *Subject: *Re: [DISCUSS] Change code style guide WRT to @Override in
>> subclasses / interface implementations
>>
>> I don’t think the guide has yet been published to the official website,
>> has it? Maybe we should just get it out there.
>>
>> On Jun 3, 2022, at 8:54 AM, benedict@apache.org wrote:
>>
>>
>>
>> Somebody hasn’t looked at the new style guide*, the conversation for
>> which keeps rolling on and so it never quite gets promoted to the wiki. It
>> says:
>>
>>
>>
>> Always use @Override annotations when implementing abstract or interface
>> methods or overriding a parent method.
>>
>>
>>
>> *
>> https://docs.google.com/document/d/1sjw0crb0clQin2tMgZLt_ob4hYfLJYaU4lRX722htTo
>>
>>
>>
>>
>>
>> *From: *Josh McKenzie <jm...@apache.org>
>> *Date: *Friday, 3 June 2022 at 16:14
>> *To: *dev@cassandra.apache.org <de...@cassandra.apache.org>
>> *Subject: *Re: [DISCUSS] Change code style guide WRT to @Override in
>> subclasses / interface implementations
>>
>> > Avoid redundant @Override annotations when implementing abstract or
>> interface methods.
>>
>> I'd argue they're not redundant. We're humans and infinitely fallible. :)
>>
>>
>>
>> +1 to changing this to just always annotate for all the reasons you
>> enumerate.
>>
>>
>>
>> On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
>>
>> Right, my thinking matches what David has mentioned:
>>
>>
>>
>> https://issues.apache.org/jira/browse/CASSANDRA-16096
>>
>> https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
>>
>>
>>
>> I'll make sure to update the style guide itself, too, since it looks like
>> there was a vote, and intellij file is updated, just need to fixup the
>> website.
>>
>>
>>
>>
>>
>> On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
>>
>> So your proposal is to always add override annotation? Or are there
>> situations where you don’t want to add them?
>>
>>
>>
>>
>>
>> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>>
>>
>>
>> Hi everyone,
>>
>>
>>
>> In our style guide [1], we have a following statement:
>>
>>
>>
>> > Avoid redundant @Override annotations when implementing abstract or
>> interface methods.
>>
>>
>>
>> I'd like to suggest we change this.
>>
>>
>>
>> @Override annotation in subclasses might be annoying when you're writing
>> the code for the first time, or reading already familiar code, but when
>> you're working on large changes and have complex class hierarchies, or
>> multiple overloads for the method, it's easy to overlook methods that were
>> not marked as overrides, and leave a wrong method in the code, or
>> misinterpret the call chain.
>>
>>
>>
>> I think @Override annotations are extremely useful and serve their
>> purpose, especially when refactoring: I can change the interface, and will
>> not only be pointed to all classes that do not implement the new version
>> (which compiler will do anyways), but also will be pointed to the classes
>> that, to the human eye, may look like they're overriding the method, but in
>> fact they do not.
>>
>>
>>
>> More concrete example: there is an abstract class between the interface
>> and a concrete implementation: you change the interface, modify the method
>> in the abstract class, but then forget to change the signature in the
>> overriden implementation of the concrete class, and get a behaviour from
>> the abstract class rather then concrete implementation.
>>
>>
>>
>> The question is not about taste or code aesthetics, but about making
>> maintaining a large codebase that has a lot of complexity and that was
>> evolving over many years simpler. If you could provide an example where
>> @Override would be counter-productive or overly burdensome, we could
>> compare this cost of maintenance with the cost of potential errors.
>>
>>
>>
>> Thank you,
>>
>> --Alex
>>
>>
>>
>> [1] https://cassandra.apache.org/_/development/code_style.html
>>
>>
>>
>>
>>
>>
>
> --
> +---------------------------------------------------------------+
> | Derek Chen-Becker |
> | GPG Key available at https://keybase.io/dchenbecker and |
> | https://pgp.mit.edu/pks/lookup?search=derek%40chen-becker.org |
> | Fngrprnt: EB8A 6480 F0A3 C8EB C1E7 7F42 AFC5 AFEE 96E4 6ACC |
> +---------------------------------------------------------------+
>
>
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Derek Chen-Becker <de...@chen-becker.org>.
+1 to publishing. We should consider it a living document, not something
that we need to necessarily set in stone :)
Cheers,
Derek
On Fri, Jun 3, 2022 at 10:05 AM benedict@apache.org <be...@apache.org>
wrote:
> I always ask if we’re ready, get a few acks, then one or two new queries
> come out of the woodwork.
>
>
>
> Perhaps I will just publish, and we can start addressing these queries in
> a follow-up process.
>
>
>
> *From: *Dinesh Joshi <dj...@apache.org>
> *Date: *Friday, 3 June 2022 at 16:57
> *To: *dev@cassandra.apache.org <de...@cassandra.apache.org>
> *Subject: *Re: [DISCUSS] Change code style guide WRT to @Override in
> subclasses / interface implementations
>
> I don’t think the guide has yet been published to the official website,
> has it? Maybe we should just get it out there.
>
> On Jun 3, 2022, at 8:54 AM, benedict@apache.org wrote:
>
>
>
> Somebody hasn’t looked at the new style guide*, the conversation for which
> keeps rolling on and so it never quite gets promoted to the wiki. It says:
>
>
>
> Always use @Override annotations when implementing abstract or interface
> methods or overriding a parent method.
>
>
>
> *
> https://docs.google.com/document/d/1sjw0crb0clQin2tMgZLt_ob4hYfLJYaU4lRX722htTo
>
>
>
>
>
> *From: *Josh McKenzie <jm...@apache.org>
> *Date: *Friday, 3 June 2022 at 16:14
> *To: *dev@cassandra.apache.org <de...@cassandra.apache.org>
> *Subject: *Re: [DISCUSS] Change code style guide WRT to @Override in
> subclasses / interface implementations
>
> > Avoid redundant @Override annotations when implementing abstract or
> interface methods.
>
> I'd argue they're not redundant. We're humans and infinitely fallible. :)
>
>
>
> +1 to changing this to just always annotate for all the reasons you
> enumerate.
>
>
>
> On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
>
> Right, my thinking matches what David has mentioned:
>
>
>
> https://issues.apache.org/jira/browse/CASSANDRA-16096
>
> https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
>
>
>
> I'll make sure to update the style guide itself, too, since it looks like
> there was a vote, and intellij file is updated, just need to fixup the
> website.
>
>
>
>
>
> On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
>
> So your proposal is to always add override annotation? Or are there
> situations where you don’t want to add them?
>
>
>
>
>
> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>
>
>
> Hi everyone,
>
>
>
> In our style guide [1], we have a following statement:
>
>
>
> > Avoid redundant @Override annotations when implementing abstract or
> interface methods.
>
>
>
> I'd like to suggest we change this.
>
>
>
> @Override annotation in subclasses might be annoying when you're writing
> the code for the first time, or reading already familiar code, but when
> you're working on large changes and have complex class hierarchies, or
> multiple overloads for the method, it's easy to overlook methods that were
> not marked as overrides, and leave a wrong method in the code, or
> misinterpret the call chain.
>
>
>
> I think @Override annotations are extremely useful and serve their
> purpose, especially when refactoring: I can change the interface, and will
> not only be pointed to all classes that do not implement the new version
> (which compiler will do anyways), but also will be pointed to the classes
> that, to the human eye, may look like they're overriding the method, but in
> fact they do not.
>
>
>
> More concrete example: there is an abstract class between the interface
> and a concrete implementation: you change the interface, modify the method
> in the abstract class, but then forget to change the signature in the
> overriden implementation of the concrete class, and get a behaviour from
> the abstract class rather then concrete implementation.
>
>
>
> The question is not about taste or code aesthetics, but about making
> maintaining a large codebase that has a lot of complexity and that was
> evolving over many years simpler. If you could provide an example where
> @Override would be counter-productive or overly burdensome, we could
> compare this cost of maintenance with the cost of potential errors.
>
>
>
> Thank you,
>
> --Alex
>
>
>
> [1] https://cassandra.apache.org/_/development/code_style.html
>
>
>
>
>
>
--
+---------------------------------------------------------------+
| Derek Chen-Becker |
| GPG Key available at https://keybase.io/dchenbecker and |
| https://pgp.mit.edu/pks/lookup?search=derek%40chen-becker.org |
| Fngrprnt: EB8A 6480 F0A3 C8EB C1E7 7F42 AFC5 AFEE 96E4 6ACC |
+---------------------------------------------------------------+
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Brandon Williams <dr...@gmail.com>.
+1, let's do that.
Kind Regards,
Brandon
On Fri, Jun 3, 2022 at 11:05 AM benedict@apache.org <be...@apache.org> wrote:
>
> I always ask if we’re ready, get a few acks, then one or two new queries come out of the woodwork.
>
>
>
> Perhaps I will just publish, and we can start addressing these queries in a follow-up process.
>
>
>
> From: Dinesh Joshi <dj...@apache.org>
> Date: Friday, 3 June 2022 at 16:57
> To: dev@cassandra.apache.org <de...@cassandra.apache.org>
> Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
>
> I don’t think the guide has yet been published to the official website, has it? Maybe we should just get it out there.
>
> On Jun 3, 2022, at 8:54 AM, benedict@apache.org wrote:
>
>
>
> Somebody hasn’t looked at the new style guide*, the conversation for which keeps rolling on and so it never quite gets promoted to the wiki. It says:
>
>
>
> Always use @Override annotations when implementing abstract or interface methods or overriding a parent method.
>
>
>
> * https://docs.google.com/document/d/1sjw0crb0clQin2tMgZLt_ob4hYfLJYaU4lRX722htTo
>
>
>
>
>
> From: Josh McKenzie <jm...@apache.org>
> Date: Friday, 3 June 2022 at 16:14
> To: dev@cassandra.apache.org <de...@cassandra.apache.org>
> Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
>
> > Avoid redundant @Override annotations when implementing abstract or interface methods.
>
> I'd argue they're not redundant. We're humans and infinitely fallible. :)
>
>
>
> +1 to changing this to just always annotate for all the reasons you enumerate.
>
>
>
> On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
>
> Right, my thinking matches what David has mentioned:
>
>
>
> https://issues.apache.org/jira/browse/CASSANDRA-16096
>
> https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
>
>
>
> I'll make sure to update the style guide itself, too, since it looks like there was a vote, and intellij file is updated, just need to fixup the website.
>
>
>
>
>
> On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
>
> So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
>
>
>
>
>
> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>
>
>
> Hi everyone,
>
>
>
> In our style guide [1], we have a following statement:
>
>
>
> > Avoid redundant @Override annotations when implementing abstract or interface methods.
>
>
>
> I'd like to suggest we change this.
>
>
>
> @Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
>
>
>
> I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
>
>
>
> More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
>
>
>
> The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
>
>
>
> Thank you,
>
> --Alex
>
>
>
> [1] https://cassandra.apache.org/_/development/code_style.html
>
>
>
>
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by "benedict@apache.org" <be...@apache.org>.
I always ask if we’re ready, get a few acks, then one or two new queries come out of the woodwork.
Perhaps I will just publish, and we can start addressing these queries in a follow-up process.
From: Dinesh Joshi <dj...@apache.org>
Date: Friday, 3 June 2022 at 16:57
To: dev@cassandra.apache.org <de...@cassandra.apache.org>
Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
I don’t think the guide has yet been published to the official website, has it? Maybe we should just get it out there.
On Jun 3, 2022, at 8:54 AM, benedict@apache.org wrote:
Somebody hasn’t looked at the new style guide*, the conversation for which keeps rolling on and so it never quite gets promoted to the wiki. It says:
Always use @Override annotations when implementing abstract or interface methods or overriding a parent method.
* https://docs.google.com/document/d/1sjw0crb0clQin2tMgZLt_ob4hYfLJYaU4lRX722htTo
From: Josh McKenzie <jm...@apache.org>
Date: Friday, 3 June 2022 at 16:14
To: dev@cassandra.apache.org <de...@cassandra.apache.org>
Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
> Avoid redundant @Override annotations when implementing abstract or interface methods.
I'd argue they're not redundant. We're humans and infinitely fallible. :)
+1 to changing this to just always annotate for all the reasons you enumerate.
On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
Right, my thinking matches what David has mentioned:
https://issues.apache.org/jira/browse/CASSANDRA-16096
https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
I'll make sure to update the style guide itself, too, since it looks like there was a vote, and intellij file is updated, just need to fixup the website.
On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
Hi everyone,
In our style guide [1], we have a following statement:
> Avoid redundant @Override annotations when implementing abstract or interface methods.
I'd like to suggest we change this.
@Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
Thank you,
--Alex
[1] https://cassandra.apache.org/_/development/code_style.html
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Dinesh Joshi <dj...@apache.org>.
I don’t think the guide has yet been published to the official website, has it? Maybe we should just get it out there.
> On Jun 3, 2022, at 8:54 AM, benedict@apache.org wrote:
>
>
> Somebody hasn’t looked at the new style guide*, the conversation for which keeps rolling on and so it never quite gets promoted to the wiki. It says:
>
> Always use @Override annotations when implementing abstract or interface methods or overriding a parent method.
>
> * https://docs.google.com/document/d/1sjw0crb0clQin2tMgZLt_ob4hYfLJYaU4lRX722htTo
>
>
> From: Josh McKenzie <jm...@apache.org>
> Date: Friday, 3 June 2022 at 16:14
> To: dev@cassandra.apache.org <de...@cassandra.apache.org>
> Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
>
> > Avoid redundant @Override annotations when implementing abstract or interface methods.
> I'd argue they're not redundant. We're humans and infinitely fallible. :)
>
> +1 to changing this to just always annotate for all the reasons you enumerate.
>
> On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
> Right, my thinking matches what David has mentioned:
>
> https://issues.apache.org/jira/browse/CASSANDRA-16096
> https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
>
> I'll make sure to update the style guide itself, too, since it looks like there was a vote, and intellij file is updated, just need to fixup the website.
>
>
> On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
> So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
>
>
> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>
> Hi everyone,
>
> In our style guide [1], we have a following statement:
>
> > Avoid redundant @Override annotations when implementing abstract or interface methods.
>
> I'd like to suggest we change this.
>
> @Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
>
> I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
>
> More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
>
> The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
>
> Thank you,
> --Alex
>
> [1] https://cassandra.apache.org/_/development/code_style.html
>
>
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by "benedict@apache.org" <be...@apache.org>.
Somebody hasn’t looked at the new style guide*, the conversation for which keeps rolling on and so it never quite gets promoted to the wiki. It says:
Always use @Override annotations when implementing abstract or interface methods or overriding a parent method.
* https://docs.google.com/document/d/1sjw0crb0clQin2tMgZLt_ob4hYfLJYaU4lRX722htTo
From: Josh McKenzie <jm...@apache.org>
Date: Friday, 3 June 2022 at 16:14
To: dev@cassandra.apache.org <de...@cassandra.apache.org>
Subject: Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
> Avoid redundant @Override annotations when implementing abstract or interface methods.
I'd argue they're not redundant. We're humans and infinitely fallible. :)
+1 to changing this to just always annotate for all the reasons you enumerate.
On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
Right, my thinking matches what David has mentioned:
https://issues.apache.org/jira/browse/CASSANDRA-16096
https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
I'll make sure to update the style guide itself, too, since it looks like there was a vote, and intellij file is updated, just need to fixup the website.
On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
Hi everyone,
In our style guide [1], we have a following statement:
> Avoid redundant @Override annotations when implementing abstract or interface methods.
I'd like to suggest we change this.
@Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
Thank you,
--Alex
[1] https://cassandra.apache.org/_/development/code_style.html
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Josh McKenzie <jm...@apache.org>.
> > Avoid redundant `@Override` annotations when implementing abstract or interface methods.
I'd argue they're not redundant. We're humans and infinitely fallible. :)
+1 to changing this to just always annotate for all the reasons you enumerate.
On Fri, Jun 3, 2022, at 10:16 AM, Alex Petrov wrote:
> Right, my thinking matches what David has mentioned:
>
> https://issues.apache.org/jira/browse/CASSANDRA-16096
> https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
>
> I'll make sure to update the style guide itself, too, since it looks like there was a vote, and intellij file is updated, just need to fixup the website.
>
>
> On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
>> So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
>>
>>>
>>> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>>>
>>> Hi everyone,
>>>
>>> In our style guide [1], we have a following statement:
>>>
>>> > Avoid redundant `@Override` annotations when implementing abstract or interface methods.
>>>
>>> I'd like to suggest we change this.
>>>
>>> @Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
>>>
>>> I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
>>>
>>> More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
>>>
>>> The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
>>>
>>> Thank you,
>>> --Alex
>>>
>>> [1] https://cassandra.apache.org/_/development/code_style.html
>
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Alex Petrov <al...@coffeenco.de>.
Right, my thinking matches what David has mentioned:
https://issues.apache.org/jira/browse/CASSANDRA-16096
https://lists.apache.org/thread/mkskwxn921t5bkfmnog032qvnyjk82t7
I'll make sure to update the style guide itself, too, since it looks like there was a vote, and intellij file is updated, just need to fixup the website.
On Fri, Jun 3, 2022, at 4:02 PM, Dinesh Joshi wrote:
> So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
>
>>
>> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>>
>> Hi everyone,
>>
>> In our style guide [1], we have a following statement:
>>
>> > Avoid redundant `@Override` annotations when implementing abstract or interface methods.
>>
>> I'd like to suggest we change this.
>>
>> @Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
>>
>> I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
>>
>> More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
>>
>> The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
>>
>> Thank you,
>> --Alex
>>
>> [1] https://cassandra.apache.org/_/development/code_style.html
Re: [DISCUSS] Change code style guide WRT to @Override in subclasses / interface implementations
Posted by Dinesh Joshi <dj...@apache.org>.
So your proposal is to always add override annotation? Or are there situations where you don’t want to add them?
>
> On Jun 3, 2022, at 6:53 AM, Alex Petrov <al...@coffeenco.de> wrote:
>
>
> Hi everyone,
>
> In our style guide [1], we have a following statement:
>
> > Avoid redundant @Override annotations when implementing abstract or interface methods.
>
> I'd like to suggest we change this.
>
> @Override annotation in subclasses might be annoying when you're writing the code for the first time, or reading already familiar code, but when you're working on large changes and have complex class hierarchies, or multiple overloads for the method, it's easy to overlook methods that were not marked as overrides, and leave a wrong method in the code, or misinterpret the call chain.
>
> I think @Override annotations are extremely useful and serve their purpose, especially when refactoring: I can change the interface, and will not only be pointed to all classes that do not implement the new version (which compiler will do anyways), but also will be pointed to the classes that, to the human eye, may look like they're overriding the method, but in fact they do not.
>
> More concrete example: there is an abstract class between the interface and a concrete implementation: you change the interface, modify the method in the abstract class, but then forget to change the signature in the overriden implementation of the concrete class, and get a behaviour from the abstract class rather then concrete implementation.
>
> The question is not about taste or code aesthetics, but about making maintaining a large codebase that has a lot of complexity and that was evolving over many years simpler. If you could provide an example where @Override would be counter-productive or overly burdensome, we could compare this cost of maintenance with the cost of potential errors.
>
> Thank you,
> --Alex
>
> [1] https://cassandra.apache.org/_/development/code_style.html