Skip to content

Unnecessary getters and setters in annotation classes #9

Open
@donquixote

Description

@donquixote

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions