Another word on namespaces

Kent Frederic’s recent post about Dist::Zilla minting profiles was a great overview of the subject, but because I try to follow best practices, I was struck by the section “A word on namespaces.”

Kent recommends that if you’re making an author pluginbundle, you should name it Dist::Zilla::PluginBundle::Author::$CPANID. This extra bit of namespacing makes life easier for many people in many ways. I was immediately convinced that he was right, and moved my author stuff into appropriate author namespaces.

Today, I wrote a testing plugin for Dist::Zilla that runs a standard Test::CPAN::Changes release test. I thought this wasn’t actually very clever, and I was surprised that nobody else had done it already. Well, I was wrong. Kent pointed this out within minutes of my release to CPAN – Randy Stauner had already written and released CPANChangesTests. I hadn’t found it in my search on the CPAN. Luckily, mine isn’t an exact duplicate. Mine lets you cheat on the filename (I use CHANGES currently).

In pointing this out, Kent suggested that testing plugins should be in a Dist::Zilla::Plugin::Test:: namespace. Again, I agree. It’s obvious when pointed out. This allows easy differentiation between two disparate categories of plugins. Some plugins alter how your dist is build, released, etc: CopyReadmeFromBuild, InstallRelease, VersionFromModule. The testing plugins are quite different. In general, they provide one or several files for t/*.t or xt/*/*.t, and don’t actually affect the build or release process at all. They’re a special kind of plugin that users often want to list or search through, and they’re actually not that similar to other Dist::Zilla plugins. I think it makes lots of sense to move them into a Test namespace.

Despite being the author of TestingMania, I only have the one testing plugin mentioned above. I encourage the authors of plugins used in my pluginbundle to rename them in future releases. I’ll be doing the same, and I’ll release new versions of my pluginbundle as the testing plugins it uses are renamed.