Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for @override in class definition #9136

Open
hkollmann opened this issue Aug 26, 2016 · 9 comments
Open

support for @override in class definition #9136

hkollmann opened this issue Aug 26, 2016 · 9 comments
Labels
enhancement New features, give me a PR!!!

Comments

@hkollmann
Copy link
Member

hkollmann commented Aug 26, 2016

In Java you can mark methods with the Annotation @OverRide to show that this method is overridden. The compiler gives a warning if you override a method without using @OverRide.
So you have a hint wich methods exists in the base class.

It would be helpfull if the qooxdoo generator could support this concept.

@jochumdev
Copy link
Contributor

Would that mean that we have "hint" all overrides with @override ?

@johnspackman
Copy link
Member

In Java, if you tag with @OverRide then it is an error if it is not overriding something... But there is also a compiler warning you can enable for every overridden method that does not specify @OverRide. In other words you can optionally choose to be warned that you are unintentionally overriding

I quite like this idea - so much so that for years I've tried to get into the habit of putting "@OverRide" in my method comments. It has most benefit when all your code complies but also back porting would be an effort; how about enabling the warning by package?

@level420
Copy link
Member

so having @override will only help if i think I've overridden a method, but have not, by e.g. mistyping the method name. The other java benefit of having a check for changed method parameters is not so valuable as we have no polymorphism in javascript/qx-oo. I'm often overriding methods and add a parameter which is handled only by the local code.

When viewing the code I've found a lot of comments in front of methods // overridden.

@oetiker
Copy link
Member

oetiker commented Aug 29, 2016

adding this feature IMHO would also entail making the existing code base use it, but thinking perl it should actually not be that hard to write a script that adds the @OverRide hints to the existing source ...

@level420
Copy link
Member

@hkollmann could you please modify your issue description and be more specific on what the use of the @override should be used and what it means? Thank you!

@johnspackman
Copy link
Member

Another time @override is useful is when you refactor the base class and rename or remove methods - I've done this a couple of times lately, had to find out why something wasn't working and I'd forgotten to follow the refactor through :oops:

@level420
Copy link
Member

But if this should react as it does in java: If @override is missing, then there should be no change to the current behaviour of the generator and the qx-compiler.

And it would NOT help when unintentionally overriding a method.

@oetiker
Copy link
Member

oetiker commented Aug 29, 2016

@level420 I think whether or not override is processed would be configurable. I guess it could be part of config.json ...

@hkollmann
Copy link
Member Author

@level420: It would help if the compiler generates a warning like Java: "method xxx is overriden without @OverRide"

@level420 level420 added the enhancement New features, give me a PR!!! label Sep 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, give me a PR!!!
Projects
None yet
Development

No branches or pull requests

5 participants