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

Unnecessary getters and setters in annotation classes #9

Open
donquixote opened this issue Aug 13, 2017 · 1 comment
Open

Unnecessary getters and setters in annotation classes #9

donquixote opened this issue Aug 13, 2017 · 1 comment

Comments

@donquixote
Copy link

From #7

donquixote:

Somehow I don't like how those annotation classes are so verbose and boilerplate-y.
But I suppose it is a matter of taste, and it would be futile trying to convince you.

slootjes:

I would rather call it explicit, a matter of taste I guess :-)

I think what I don't like is all the setters and getters, made necessary by the base class ConfigurationAnnotation, and its constructor mechanics.
The setters are only called in a "magical" way in the constructor.
Also the getters are never going to be called from outside.

So..

  • setters could be protected
  • getters could be private
  • getters could be removed completely, and the modifyRoute() would directly access the private properties instead.

I was thinking that the base class could be replaced. The constructor would then write to the private properties directly instead of calling the setters. However, to do this from a base class, the properties would have to be protected instead of private. I like private :) So this means the setters should stay, but can be protected.

I was also thinking to remove the private properties completely and replace them with an associative array. However, this would prevent the PhpStorm annotation plugin from doing autocomplete.

@slootjes
Copy link
Contributor

Setters can probably be set to protected but the getters should remain public since other services might also want to read these annotations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants