如何构建不同版本的Web应用程序的代码稍有不同? [英] How to structure code for different version of web app which vary slightly?

查看:127
本文介绍了如何构建不同版本的Web应用程序的代码稍有不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用EmberJS在这个网络应用程序上工作。这个应用程序将有两个版本 - 一个英国和一个美国版本。它们在具体内容上略有不同,但总体上将保持非常相似。例如,不是在仪表板X,Y,Z功能中显示,而是可能是X,Z和A.我想知道最好的代码结构,以避免重复的代码,并且易于维护。

I'm currently working on this web app using EmberJS. This app will have two version -- a UK and a US version. They both vary slightly in specific content, but overall will remain VERY similar. For instance, instead of displaying in the dashboard X, Y, Z features, it might be X, Z, and A. I would like to know the best code structure to avoid duplicate code and for it to be easily maintainable.

我目前关于如何解决这个问题的想法是为不同的特定部分加载不同的文件。例如,我有一个plan.html页面,但在其中我有一个元素视图。元素视图是两个版本不同的部分。在这种情况下,我想要有两个文件元素-view-us和elements-view-uk,它们都包含元素视图,但是内容不同。这样我可以根据请求的版本加载正确的文件。这是一个很好的解决方案还是有更好的解决方案?谢谢。

My current thoughts on how to solve this are to load different files for the specific parts that will be different. For instance, I have a plan.html page, but within it I have an elements view. The elements view is the part that is different in both versions. In this case, I'd like to have two files elements-view-us and elements-view-uk, both which contain the elements view, but with different the content. This way I can just load the correct file depending on the version that is requested. Would this be a good solution or is there a better one? Thanks.

推荐答案

这是一个很好的解决方案,很容易测试,很少重复。

That's a good solution easy to test, very little duplication.

大多数应该在部署时处理,部署某些文件到我们的服务器/某些到英国的服务器。除非它将全部托管在同一个服务器上,那么我喜欢方法1捆绑等

Most of this should be handled at deploy time tho, deploy certain files onto us servers/ certain to uk severs. Unless it will all be hosted on the same server, then i like approach 1 with bundling etc

这篇关于如何构建不同版本的Web应用程序的代码稍有不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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