鏡像問題

為什麼前端老覺得後端簡單??

www.zhihu.com圖標


因為前後端看待問題的方式不同。

前端的複雜度主要在如何優雅地處理

  • 用戶交互體驗好且簡潔
  • 瀏覽器兼容
  • 移動端自適應適配
  • 完美」像素級拷貝「設計師的原型
  • 等其他看上去比較小的細節

而對於高並發、存儲過程等並不十分在意。

前端與後端

而後端的複雜度主要體現在如何完美應對

  • 高並發、load balancer
  • CDN 緩存靜態文件(現在大多是 ops 負責)
  • 文件同步、鎖
  • 存儲過程
  • 加密
  • 等雖然表面看不到,但是實際處理起來非常費勁的任務

由於對待」簡單「和」複雜「的標準不同,就有了截然不同的評價。

如果把看得見的」冰山一角「比作前端,則看不見海水下面的冰山就是」後端「

當一個後端不得不調試 CSS 的時候,可能會覺得 CSS 很簡單,因為似乎怎麼寫都可以達到目標。但殊不知由於 CSS 不是正交(non-orthogonal)的特性,有時候很簡單的一個寫法卻會引起某種意想不到的效果,更不談瀏覽器兼容性問題等等。

一個著名的例子:外邊距摺疊(margin collapsing)[1]

HTML:

&

The bottom margin of this paragraph is collapsed …&

&

… with the top margin of this paragraph, yielding a margin of &20px& in between.&

&This parent element contains two paragraphs!
&

This paragraph has a &20px& margin between it and the text above.&

&

My bottom margin collapses with my parent, yielding a bottom margin of &20px&.&

&

相关文章