接下來我們來講講SOLID的O - OCP,開放封閉原則。 核心觀念定義 如果說 SRP 是為了整理程式碼,那麼 OCP 就是為了保護程式碼。它是防止「新需求搞壞舊功能」的最強盾牌。 “Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.” — Bertrand Meyer 「軟體實體應該對『擴充』開放,但對『修改』封閉。...
blog.bennett1999.com3 min readNo responses yet.