Rails 构建可激活(或不可激活)功能的最佳实践?
好吧,假设我有一个看起来很棒的 Rails 应用程序,其中包含一些帖子,可以对其进行评论和投票。它在线,人们喜欢它。
现在想象一下,一位客户出现并告诉我“嘿,这个应用程序看起来不错!我可以拥有同一个应用程序,但在评论中也带有我的徽标和投票吗?”
好吧,我克隆应用程序,进行更改,然后将调整后的应用程序交付给客户,然后返回原始应用程序并继续使其变得更好。
几个月后,另一位客户来了,也想要相同的应用程序(现已改进),但也对评论进行投票。
当然,我意识到克隆应用程序一开始就不是一个聪明的主意。
我想知道的是,您将如何从一开始就使其变得简单、可维护且干燥,以便在第二个项目中重用为第一个客户提供的功能?
然后想象一下,许多客户都有许多不同的需求功能。现在您意识到,能够仅使用此功能或此功能“构建”一个新应用程序,而不是此功能,等等,这真是太棒了。
你将如何实现这一目标?
我想 git 分支可能是实现这一目标的好方法,或者可能是 Rails Engine/Gems,或者我不知道,但我绝对没有足够熟练的 git 或 Rails 来清楚地看到漏洞图片。
谢谢 !
OK let's assume I have an awesome looking rails app with somes Posts, which can be commented and voted on. It's online and people love it.
Now imagine a client comes up and tells me "Hey, this app looks good ! Could I have just the same one, but with my logo and votes also on comments ?"
So ok I clone the app, make the changes, then I deliver the tweaked app to the client, and then I get back to my original app and continue to make it better.
A couple on months later another client come and also wants the same app (now improved) but with votes also on comments.
Of course I realize cloning the app in the first place was not a clever idea.
What I'd like to know is how would you do from the beginning to make it as easy, maintainable and DRY to reuse the feature made for the first client in the second's project ?
Then imagine lots of clients come with lots of different requested features. Now you realize it would be just awesome to be able to 'build' a new app with just this feature or this one, but not this one, and so forth.
How would you achieve that ?
I imagine git branches could be a nice way to achieve that, or maybe Rails Engines/Gems, or I don't know, but I'm definitely not git or rails skilled enough to clearly see the hole picture.
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们公司也遇到过同样的情况,我们做了许多不同的事情来使我们的开发更加模块化。
其一,我们使用一些内部 gem 和 Rails 引擎。例如,我们开发了一个博客引擎,几乎在每个项目中都推出了该引擎。
另一种选择可能是担忧。例如,您可以将评论系统推断为一个问题,然后将其移植到具有类似需求的其他项目。
或者(也许是我最不喜欢的选择)是为每个功能维护一些 git 存储库,并使用 git 模块将它们添加到您的项目中。
We've had the same situation in our firm and we've done a number of different things to make our development more modular.
For one, we use a few internal gems and Rails engines. For example, we developed a blogging engine that we launch with pretty much every project.
Another option might be concerns. For example, you could extrapolate the commenting system into a concern and just port that over to the other projects with similar needs.
Alternatively (and, perhaps, my least favorite option) would be to maintain a few git repos with each feature and use git modules to add them to your project.