避免使用第三方宝石是否正确? [英] Is it right to avoid using third-party gems?

查看:87
本文介绍了避免使用第三方宝石是否正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ruby on Rails 3.2.2。我想知道下面的想法(从我的


我倾向于不使用第三个第四方宝石(至少在可能和合理的情况下),因为它们可能随时被抛弃。另外,如果Ruby on Rails框架发生变化,我可能不得不等待这些宝石更新,然后再将我的应用程序更新到最新的RoR版本。




但在现实世界中,人们已经为你解决了问题已经。宝石允许你插入这些解决方案。



一个好的经验法则是在可行的情况下,选择社区最喜欢的/流行的宝石作为给定的解决方案。使用宝石的人越多,人们越有兴趣保持它的更新,并且更多的眼球正在仔细检查并发送请求。有可能是一群在生产环境中受到一群人战斗考验的宝石比你第一次尝试时想出来的要好,对吗?

宝石这取决于一个业余爱好者的维护者,甚至没有在自我搔痒的生产应用中使用它,你往往会发现一些风险。但即使在这种情况下,如果你最终不得不在某个时候掏出他的宝石,那么如果你从头开始的话,你仍然会处在你以前的状态。



一个更好的趋势是避免从头开始写所有东西,而是利用其他有类似需求的人的大脑。


I am using Ruby on Rails 3.2.2. and I would like to know if the following thought (born from my previous question) is correct:

I tend not to use third-party gems (at least when it is possible and reasonable) because they might be abandoned at any time. Also, if the Ruby on Rails framework changes, I might have to wait for those gems to be updated before updating my application to the latest RoR version.

解决方案

In a perfect world where you're immortal, have infinite time, are the world's best programmer, and it makes no difference whether you launch your product in 1 hour or 10 years so you can code everything yourself from scratch, then maybe it makes more sense to avoid the code of other people.

But in the real world, people have solved problems for you already. And gems allow you to plug in those solutions.

A good rule of thumb is to prefer the community's favorite/popular gems for a given solution when you can. The more people using a gem, the more people have an interest in keeping it updated and the more eyeballs are scrutinizing it and sending pull requests. Chances are that a gem that's battle-tested by a bunch of people in production environments is better than what you'd come up with on your first attempt, right?

Gems that depend on one hobbyist maintainer that's not even using it in a self-itch-scratching production application are where you tend to find some risk. But even in those situations, if you end up having to fork his gem one day, you're still ahead of where you'd be if you started from scratch.

A better tendency is to avoid writing everything from scratch and instead leverage the brains of other people with similar needs.

这篇关于避免使用第三方宝石是否正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆