Web服务和API:"鸡还是先有蛋" [英] Web service and API: "chicken or egg"

查看:186
本文介绍了Web服务和API:"鸡还是先有蛋"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将要开发一个Web服务,这将有一些社会的特点。
我们需要创建一个(响应)的网站和应用程序移动(的iOS / Android的至少)。

We are about to develop a web service, which will have some "social" features. We will need to create a (responsive) web site and apps for mobile (iOS/Android at least).

我已经开发了具有网络的API服务(应用程序的访问;通常不公开)。不过,这一次我想应聘不同,恢复的办法,我想关于它的一些看法。

I have already developed web services which have APIs (for app access; generally not public). However, this time I was thinking about applying a different, reverted approach, and I would like some opinions about it.

除了开发网站,然后在它的上面添加的API让应用程序与服务通信的,我想从API的开始,然后建立在它之上的一切(包括网站)。会有那么,是服务(要么是PHP或Node.js的应用程序)与所述数据库通信,并且两个所述网站(服务器端,而不是客户端)和应用程序将与该服务器通信。

Instead of developing the web site and then add APIs on top of it for letting the apps communicate with the service, I was thinking to start from the APIs and then build everything (including the web site) on top of it. There will, then, be a service (either a PHP or Node.js app) which communicates with the database, and both the web site (on server-side, not client-side) and the apps will communicate with this server.

这种方法的优点正:


  1. 数据和视图之间完全分离。该网站将高于API后端不同的,独立的服务器上运行。

  2. 可能更具可扩展性

不过,我也知道,这种方法需要创建网站和数据库之间的额外层,这可能会产生负面影响性能。

However, I am also aware that this approach requires creating an extra layer between the web site and the database, and this could impact performances negatively.

你觉得呢?你有这个设计经验,或个案研究?

What do you think? Do you have experience with this design, or case studies?

推荐答案

这是一个非常适合的做法,是由许多公司,包括我成功地使用的。

This is a perfectly suitable approach and one that is used successfully by many companies, including mine.

我们倾向于先从一个API套件,允许​​访问的JavaScript / HTML Web的应用程序。我们predominantly使用AngularJS来创建Web应用程序。

We tend to start with an API suite which permits access to Javascript/HTML web-applications. We predominantly use AngularJS to create the web application.

作为一个额外层(你已经确定),我们有时也创造了更传统的服务器端应用程序作为Web服务的客户。这往往感觉不仅仅是创建具有不同(但相近)子系统单独的应用程序,例如数据访问,验证很多工作。然而,一旦你已经建立这些图层和主应用程序,您得到Web服务是免费的!你可以用一些文档发布API套件集成合作伙伴使用,并且可以在同一个后端为你的web应用程序构建移动应用程序。

As an extra-layer (which you have identified) we sometimes also create more traditional server-side applications as clients of the web-service. This often feels like a lot more work than just creating seperate applications with different (but similar) subsystems, for example data-access, authentication. However once you have built these layers and "primary" applications you get the webservices for free! and you can publish the API suite with some documentation for integration partners to use, and you can build mobile applications on the same backend as your web-applications.

我们发现的主要好处是,有较少的测试和维护作为项目的成熟,同时保留了异构连接的客户端。

The major benefit we find is that there is less to test and maintain as the projects mature, whilst retaining heterogenous connecting clients.

最好的运气

这篇关于Web服务和API:"鸡还是先有蛋"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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