如何命名类/包/模块,例如
如果一个包的唯一目的是扩展另一个模块以便您可以对其应用角色,您会如何命名该包?我需要一个扩展(子类) Template::Context 的包 和 Moose 这样我就可以创建角色和特征应用于它,但我不知道如何命名这个包(类)。有什么建议吗?
How would you name a package who's sole purpose was to extend another module so you could apply roles to it? I need a package that extends (sub classes) Template::Context with Moose So I can then create roles and traits to apply to it, but I don't know what to name this package (class). Any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于它是驼鹿特定的角色化,所以我在名字中加入了驼鹿。模板::上下文::Moosified。或 Template::Context::WithAntlers。
但是拥有一个中间子类只是为了让你可以将角色附加到它上面,这很奇怪。您可以跳过该中间人,直接声明组合类。
类名应该不属于角色构成。
Since its Moose-specific role-ification, I'd have Moose in the name. Template::Context::Moosified. Or Template::Context::WithAntlers.
But having an intermediate subclass just so you can stick roles onto it is weird. You can skip that middleman and simply declare composed classes directly.
The class name should fall out of the role composition.
我不确定这是否已获得批准,但您始终可以尝试直接应用该角色。
当然,这需要一些补充,绝对不能保证长期有效,而且可能完全不受支持。然而,这就是无糖 MOP 的有效工作原理。
I'm not sure this is approved but you can always try applying the Role directly.
Granted this needs some sugaring up, has absolutely no guarantees to work long term, and is probably totally unsupported. This is however how the MOP unsugared effectively works.