Web 应用程序使用 API 来处理所有事情? [英] Web app using API for everything?

查看:24
本文介绍了Web 应用程序使用 API 来处理所有事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我即将开始为我的公司规划一个内部项目管理工具.一直让我想知道的一件事是 API.

I'm about to start planning an internal project management tool for my company. One thing that has always led me wondering is APIs.

首先创建 API 并使用这些 API 调用构建实际站点而不是实施两次是否会被视为不好的做法/效率太低?

Would it be seen as bad practice / too inefficient to create a API first and build the actual site using those API calls rather than implement it twice?

让我知道你的想法!

推荐答案

我完全同意开发 API 会给你一个解耦的架构,我建议这样做.

I completely agree that developing an API will give you a decoupled architecture, and I recommend that.

但是,我觉得应该警告您,首先开发 API 会增加您开发错误 API 的风险(顺便说一下,PM 主要是为了降低项目风险).您还可能会尝试为您的 API 镀金——程序功能可能未被使用,这会浪费时间.与应用程序一起开发 API 可确保它正确地满足实际应用程序或应用程序的需求.除非您对要求的准确性和理解有信心,否则我建议您对应用程序一次编写一个功能的 API.

However, I feel you should be warned that developing the API first increases your risk of developing the wrong API (PM, by the way, is largely about reducing project risk). You will also be tempted to gold-plate your API-- program features that may go unused, which wastes time. Developing the API in conjunction with the application guarantees that it correctly serves the actual application's or applications' needs. Unless you are confident in the accuracy of and your understanding of the requirements, I suggest programming the API one feature at a time with the application.

例如,当您开发应用程序并发现需要进行 API 调用的精确点时,创建一个看起来与您需要的完全一样的接口(取决于技术).您可以存根该界面以使应用程序运行,这是检查应用程序是否仍符合用户期望的好工具.(您希望它像这样工作,对吗?")稍后,您可以实现该接口.如果偶然的需求发生变化,您就不会花时间构建现在已经过时的基础架构.

For example, as you develop the application and discover the precise point at which you need to make an API call, create an interface (depending on the technology) that looks exactly like what you need. You can stub that interface to get the app to run, which is a great tool for checking that the app is still on track with user expectations. ("You want it to work like this, right?") Later, you can implement that interface. If by chance requirements suffer alteration, you won't have spent time building now obsolete infrastructure.

这篇关于Web 应用程序使用 API 来处理所有事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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