Is it right to avoid using third-party gems?

2019-06-28 08:23发布

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.

5条回答
时光不老,我们不散
2楼-- · 2019-06-28 08:40

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楼-- · 2019-06-28 08:40

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.

查看更多
闹够了就滚
4楼-- · 2019-06-28 08:49

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.

查看更多
Emotional °昔
5楼-- · 2019-06-28 08:51

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...

查看更多
干净又极端
6楼-- · 2019-06-28 08:53

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

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.

查看更多
登录 后发表回答