Rails Rails 中有哪些工厂模式的例子吗?

lengcb · 2018年07月11日 · 最后由 Rei 回复于 2018年07月12日 · 2087 次阅读

rails 中有哪些工厂模式应用的例子吗?看书说工厂模式是将模板方法模式应用到对象创建上,好像是这么一回事。

去看 java 吧

Dependency Injection is an example of a popular new Java design pattern that programmers using Ruby, Python, Perl and JavaScript have probably never heard of. And if they've heard of it, they've probably (correctly) concluded that they don't need it. Dependency Injection is an amazingly elaborate infrastructure for making Java more dynamic in certain ways that are intrinsic to higher-level languages. And – you guessed it – DI makes your Java code base bigger.
http://steve-yegge.blogspot.com/2007/12/codes-worst-enemy.html

huobazi 回复

java 的很早之前看过,最近买了一本盗版的《ruby 设计模式》在看

Rei 回复

https://github.com/hanami/controller#actions 还是有依赖注入概念的,今年 RubyKaigi 那场 Hanami 的演讲也涉及 DI 不少的篇幅,这个被列为 Hanami 和 Rails 不同点之一

jasl 回复

And if they've heard of it, they've probably (correctly) concluded that they don't need it.

需要 登录 后方可回复, 如果你还没有账号请 注册新账号