Codeigniter 中的辅助类 - 它们真的很糟糕吗?为什么?
我正在使用帮助程序类开发我的系统,并且我在多个来源中看到,在面向对象编程中不建议使用“帮助程序类”。
如果是这样,为什么它们被认为是坏的?
他们如何使用Codeigniter的MVC框架?
谢谢
I am developing my system with helper classes and I see on several sources that say "Helper classes" are not recommended in object orientated programming.
If so, why are they considered bad?
How do they play in with the MVC framework of Codeigniter?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
助手的优点和缺点是它们不能很好地融入 MVC 框架;它们更像是胶水,而不是木头或钢框架。它们可以在多种情况下方便使用,并且非常适合常见的轻型任务。如果您的助手变得更加复杂并开始需要与模型和控制器进行交互,那么您的设计很可能存在问题,需要更仔细地考虑。胶水和胶带可能有用,但你很难找到用它们制成的摩天大楼。
The strength and weakness of the helpers is that they don't neatly fit into the MVC framework; they're more like glue than wood or steel framing. They can be convenient to use in several contexts and are well-suited for common, light tasks. If your helpers become more complex and start needing to interact with models and controllers, odds are you've got a questionable design that needs to be more carefully considered. Glue and duct tape may be useful, but you'll be hard-pressed to find a skyscraper made of them.