前後端分離開發

爲什麼要前後端分離開發?

前端UI搭建得差不多了,可是後臺的API還沒有寫好,那就丟下工作嗨起來?可惜這樣的好願望就被Mock和Swagger這樣的破東西給毀了,項目可以解藕,人也是可以的,只要雙方有接口文檔的約定。

接口文檔解決方案

1.Swagger,寫起來太費勁,修改接口的同時還需要修護文檔,增加工作量。
2.SosoApi,簡化了Swagger的書寫,但是把接口文檔放在網上會有一定的安全隱患。
3.RAP,接口書寫非常簡單,非常容易上手,但沒有在線測試接口的功能。
4.Postman,測試就是文檔,文檔就是測試,無需維護成本。缺點是無法精確定義字段用處,只能靠字段名進行推測。
5.SoapUI
6.apiary

什麼是Swagger?

Swagger是一個規範和完整的框架,用於生成、描述、調用和可視化 RESTful 風格的 Web 服務。總體目標是使客戶端和文件系統作爲服務器以同樣的速度來更新。文件的方法,參數和模型緊密集成到服務器端的代碼,允許API來始終保持同步。
個人覺得,swagger的一個最大的優點是能實時同步api與文檔。在項目開發過程中,發生過多次:修改代碼但是沒有更新文檔,前端還是按照老舊的文檔進行開發,在聯調過程中才發現問題的情況(當然依據開閉原則,對接口的修改是不允許的,但是在項目不穩定階段,這種情況很難避免)。

What is Mocking?

What is Mocking? Let’s try a definition:
“Service Mocking, or simulation, is the practice of creating a facsimile environment that works similar to the environment you’re facsimileing”.
That’s fancy speak for saying “You build something that works as something else”
Mocking is also called Isolation, Simulation, or Virtualization, but those are term basically created to move the lowly practice of mocking higher into the value chain. So, for all purposes Isolation, Simulation, and Virtualization are the same as mocking, just much more expensive. Let’s call it mocking and move on to the uses of it.

When do I Use Mocking?

Simple; you should use mocks when you can’t use the real thing. Of course it’s not that easy when you look into it more carefully, so let’s look at some of the how’s and what’s.

Not finished, updating…

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章