During my initial work with this component, I wrote this blog post about redundant components in namespaced symbols.
I see several places in this component where we can improve the use of namespaces.
I do want to specifically mention one case, however. The exceptionality of this case wasn't obvious to me at first: Drupal\DrupalExtension.
You can see in the blog post that my initial thought was that Drupal\Extension would be more appropriate. However, I don't want to "go there" presently, because I recognize the pattern of Drupal\, and that's fine.
However, there are still several cases where this principle can be employed. Consider the following fully-qualified symbols in this project:
\Drupal\DrupalExtension\Definition\Proposal\AnnotatedDefinitionProposal
\Drupal\DrupalExtension\Context\ClassGuesser\DrupalContextClassGuesser
\Drupal\DrupalExtension\Selector\RegionSelector
\Drupal\DrupalExtension\Context\DrupalContext
\Drupal\DrupalExtension\Context\Initializer\DrupalAwareInitializer
For what it's worth, I want to mention what I see as exemplary of what I am suggesting:
\Drupal\DrupalExtension\Compiler\DriverPass
There are two direction we can go with this:
- fewer namespaces, verbose local symbols
- lightweight local symbols via hierarchy of namespaces
An example of the first technique:
\Drupal\DrupalExtension\Definition\Proposal\AnnotatedDefinitionProposal
// becomes
\Drupal\DrupalExtension\AnnotatedDefinitionProposal
An example of the second:
\Drupal\DrupalExtension\Definition\Proposal\AnnotatedDefinitionProposal
// becomes
\Drupal\DrupalExtension\Definition\Proposal\Annotated
Both of these remove unnecessary redundancy in the names.
The choice can be made based on a number of factors, but the second is *probably* better if we have chosen decent component names already. In fact, if that's a given, I'll just say that the second way is my clear preference. I'll save the discussion between \Definition\Proposal\ and \DefinitionProposal\ for another day.
Comments
Comment #1
jhedstromI haven't had a chance to read the post referenced above, but I'll try to clarify the current thinking in this project.
The namespacing follows the conventions put forth in Behat. In the case of
Drupal\DrupalExtension, that is followingVendor\Name, and might eventually change toBehat\DrupalExtension.In the other cases mentioned, these are namespaced to match that of the namespace structure of the class that is being extended in the main Behat project.
Comment #2
Crell commentedI think the issue here is that Drupal\DrupalExtension is somewhat following the naming convention for Drupal modules (Drupal\$module_name), but it's violating the other convention that Drupal modules should not have "drupal" in their name. (Which I don't think is written down anywhere, but is definitely not a good practice.)
Comment #3
jhedstromRegarding places where this project is creating it's own concepts (currently places like the Drivers), it makes sense to remove the redundancy, eg,
Drushinstead of the currentDrushDriver, etc.re #2 this isn't a module, but rather an extension of Behat, thus the
drupalextensionmachine name, leaving openextensionfor something else.Comment #4
ctrahey commentedFWIW, I'm digging more and more into Behat code these days (already one PR pending). I'll be making similar chatter over there, though hopefully I will more readily produce patches/PRs for them. Given the scenario, then, I can see this hinging a little on the outcome of the Behat team's reaction to the idea (insofar as the patterns here are following the lead of Behat components). I'm with you on the non-inherited concepts, though.
Comment #5
clemens.tolboomIt this still relevant? Minor?
Comment #6
jhedstromMarking closed for now. Like I said above, most of the namespace/class-names follow the Behat conventions, but it is worth keeping this in mind during the port to Behat 3.