避免使用第三方宝石是正确的吗?

时间:2023-01-19 10:59:14

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:

我正在使用Ruby on Rails 3.2.2。我想知道以下的想法(从我之前的问题出生)是否正确:

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.

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

5 个解决方案

#1


12  

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.

在一个完美的世界里,你是不朽的,拥有无限的时间,是世界上最好的程序员,无论你是在1小时还是10年内推出你的产品都没有区别,所以你可以从头开始自己编写所有代码,然后它可能会产生更多意识到避免别人的代码。

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.

更好的趋势是避免从头开始编写所有内容,而是利用具有类似需求的其他人的大脑。

#2


4  

Well, it's the risk you're taking in exchange for saved development time/budget and shorter time-to-market.

嗯,这是您为节省开发时间/预算和缩短产品上市时间所带来的风险。

If you find yourself in a situation when one of your gems is abandoned, then you could look at similar gems or fork and improve that one. Either way, it's still better than developing everything by yourself.

如果你发现自己的某个宝石被抛弃了,那么你可以看一下类似的宝石或叉子并改进它。无论哪种方式,它仍然比自己开发一切更好。

#3


1  

Abandon this philosophy! A lot of websites/companies tend to do this -- it's better known at the "Not invented here" syndrome. Twitter, in particular, is a big offender. Open source is great -- use it.

放弃这个哲学!许多网站/公司都倾向于这样做 - 它在“Not invented here”综合症中更为人所知。特别是推特,Twitter是一个大罪犯。开源很棒 - 使用它。

#4


1  

A work is perfectly finished only when nothing can be added to it and nothing taken away. – Joseph Joubert

只有当没有任何东西可以添加到任何东西并且没有被带走时,工作才能完美地完成 - 约瑟夫·朱伯特

That's the same philosophy we follow with our Rails projects at work. If you want to add a gem to the Gemfile, you basically have to argue it in. If you can't find a good reason why it should be in there, it will get kicked out. We are definitely not trying to reinvent the wheel, but keeping the number of potentially badly maintained moveable parts down is IMHO a good choice. So say yes to well-maintained and established Rails plugins, but be wary about stuff that looks like a quickly thrown together solution. More often that not you end up maintaining your own patches of it or forking the repo, so you might have as well reinvented that particular wheel...

这与我们在工作中使用Rails项目时所遵循的理念相同。如果你想在Gemfile中添加一个gem,你基本上不得不争论它。如果你找不到它应该在那里的一个很好的理由,它就会被淘汰出局。我们绝对不会试图重新发明*,但保持可能维护不良的可移动部件的数量是恕我直言,这是一个不错的选择。所以对维护良好且已建立的Rails插件说“是”,但要注意看起来像快速抛出的解决方案的东西。更常见的是,不是你最终维护自己的补丁或分配回购,所以你可能已经重新发明了特定的*......

#5


0  

Try, for example,devise gem, and then implement its functionality yourself. So you can define your own vision of the problem.

例如,尝试设计gem,然后自己实现其功能。因此,您可以定义自己对问题的看法。

I prefer to use all gems, which I found useful. If after update any gem doesn't work, you can always fork and upgrade it.

我更喜欢使用我认为有用的所有宝石。如果更新后任何gem都不起作用,您可以随时进行分叉和升级。

#1


12  

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.

在一个完美的世界里,你是不朽的,拥有无限的时间,是世界上最好的程序员,无论你是在1小时还是10年内推出你的产品都没有区别,所以你可以从头开始自己编写所有代码,然后它可能会产生更多意识到避免别人的代码。

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.

更好的趋势是避免从头开始编写所有内容,而是利用具有类似需求的其他人的大脑。

#2


4  

Well, it's the risk you're taking in exchange for saved development time/budget and shorter time-to-market.

嗯,这是您为节省开发时间/预算和缩短产品上市时间所带来的风险。

If you find yourself in a situation when one of your gems is abandoned, then you could look at similar gems or fork and improve that one. Either way, it's still better than developing everything by yourself.

如果你发现自己的某个宝石被抛弃了,那么你可以看一下类似的宝石或叉子并改进它。无论哪种方式,它仍然比自己开发一切更好。

#3


1  

Abandon this philosophy! A lot of websites/companies tend to do this -- it's better known at the "Not invented here" syndrome. Twitter, in particular, is a big offender. Open source is great -- use it.

放弃这个哲学!许多网站/公司都倾向于这样做 - 它在“Not invented here”综合症中更为人所知。特别是推特,Twitter是一个大罪犯。开源很棒 - 使用它。

#4


1  

A work is perfectly finished only when nothing can be added to it and nothing taken away. – Joseph Joubert

只有当没有任何东西可以添加到任何东西并且没有被带走时,工作才能完美地完成 - 约瑟夫·朱伯特

That's the same philosophy we follow with our Rails projects at work. If you want to add a gem to the Gemfile, you basically have to argue it in. If you can't find a good reason why it should be in there, it will get kicked out. We are definitely not trying to reinvent the wheel, but keeping the number of potentially badly maintained moveable parts down is IMHO a good choice. So say yes to well-maintained and established Rails plugins, but be wary about stuff that looks like a quickly thrown together solution. More often that not you end up maintaining your own patches of it or forking the repo, so you might have as well reinvented that particular wheel...

这与我们在工作中使用Rails项目时所遵循的理念相同。如果你想在Gemfile中添加一个gem,你基本上不得不争论它。如果你找不到它应该在那里的一个很好的理由,它就会被淘汰出局。我们绝对不会试图重新发明*,但保持可能维护不良的可移动部件的数量是恕我直言,这是一个不错的选择。所以对维护良好且已建立的Rails插件说“是”,但要注意看起来像快速抛出的解决方案的东西。更常见的是,不是你最终维护自己的补丁或分配回购,所以你可能已经重新发明了特定的*......

#5


0  

Try, for example,devise gem, and then implement its functionality yourself. So you can define your own vision of the problem.

例如,尝试设计gem,然后自己实现其功能。因此,您可以定义自己对问题的看法。

I prefer to use all gems, which I found useful. If after update any gem doesn't work, you can always fork and upgrade it.

我更喜欢使用我认为有用的所有宝石。如果更新后任何gem都不起作用,您可以随时进行分叉和升级。