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
Naming of classes like Manager
#8115
Comments
This is the issue for the plugin manager problem: #7656 The thing with Another issue is that it means importing the whole namespace, whereas having the list of imported class at the top of the file is very useful to get an idea of how much this class is decoupled/coupled to other classes (it serves as a good indicator IMO). I don't have so much of a problem with the "manager" word though (even though it's not the main point of this issue). Naming in Piwik is currently source of many problems and we are on the opposite side of DDD. So I'd rather go with dull yet consistent names because it would be more useful to the project, and it would be simpler to plugin developers, contributors, etc. That's why I argue for Generally I like names that describe what we are dealing with.
That's the only advantage I can see, but to me it's far fetched. On the contrary I find it easier to rename
Why would there be subclasses? |
So far that's the only advantage I can see and mentioned as well before but I personally don't use it that way. Others might do.
That's true. I'm not sure if it's that important though. You can usually also see it by having a look at the constructor or you can usually also see it by other indicators or when scrolling over the file.
Eg
vs
I don't have a very strong opinion here but wanna clarify things and come to one solution that we can use in most of the cases across the code bases. Maybe we can get some more feedback from other devs? Maybe there are some blog posts about this that could be interesting? |
This RFC didn't lead anywhere, so we're closing it |
I hope there is not already an issue about this since I can remember we had this topic already once re
Plugin\Manager
or so.See comment here: #8045 (comment) where we have a class like
Piwik\Measurable\Type\Manager
. We already have a couple of classes likeManager
(we knowManager
is not a good name see eg http://www.slideshare.net/pirhilton/how-to-name-things-the-hardest-problem-in-programming but it's not about that particular name). There are suggestions to name such classes egPiwik\Measurable\Type\Manager
Piwik\Measurable\Type\TypeManager
Piwik\Measurable\Type\MeasurableTypeManager
to not having to write eg
use Piwik\Measurable\Type\Manager as TypeManager
.I usually just use it in the code directly like this
new Type\Manager()
. This way I do not have to write theuse ... as ...
and it is still clear what is meant. So justManager
is usually ok for me personally but I can understand that it can be sometimes confusing to find the correctManager
class immediately when searching for the class name in eg PHPStorm. Still I personally prefer justManager
. For example it also allows us to change the wordingType
without having to refactor the classTypeManager
etc.Goal of this issue is to maybe agree on a naming issue to have a consistent naming in Piwik and avoiding having discussions about this in PRs.
If we name the class eg
TypeManager
where would be put "subclasses" of it. In namespacePiwik\Measurable\Type\Manager\Whatever*
orPiwik\Measurable\Type\TypeManager\Whatever\*
?In this case there might be also many
Type
classes. So would it be likePiwik\Measurable\MeasurableType\MeasurableTypeManager\Whatever\*
?The text was updated successfully, but these errors were encountered: