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

lengcb · July 11, 2018 · Last by Rei replied at July 12, 2018 · 2087 hits

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

Reply to huobazi

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

Reply to Rei

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

Reply to jasl

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

You need to Sign in before reply, if you don't have an account, please Sign up first.