鏡像問題為什麼前端老覺得後端簡單??www.zhihu.com
鏡像問題
因為前後端看待問題的方式不同。
前端的複雜度主要在如何優雅地處理
而對於高並發、存儲過程等並不十分在意。
而後端的複雜度主要體現在如何完美應對
由於對待」簡單「和」複雜「的標準不同,就有了截然不同的評價。
當一個後端不得不調試 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&.& &
The bottom margin of this paragraph is collapsed …&
… with the top margin of this paragraph, yielding a margin of &20px& in between.&
20px&
&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&.&