---
title: "Discussion on \"Lesson 17: SOLID 實戰篇 (2)-開放封閉 (OCP) - 擁抱變化而不修改舊碼\" | Hashnode"
description: "Discussion on \"Lesson 17: SOLID 實戰篇 (2)-開放封閉 (OCP) - 擁抱變化而不修改舊碼\". 深入解析 SOLID 中的 OCP（開放封閉原則），說明如何透過策略模式實現「對擴充開放、對修改封閉」，並結合訂單折扣與 Laravel 實務範例，避免修改既有程式碼造成的回歸風險。"
url: "https://hashnode.com/posts/solid-ocp/6947a2ef91e157a216ac255b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Lesson 17: SOLID 實戰篇 (2)-開放封閉 (OCP) - 擁抱變化而不修改舊碼](https://blog.bennett1999.com/solid-ocp?utm_source=hashnode&utm_medium=feed)

深入解析 SOLID 中的 OCP（開放封閉原則），說明如何透過策略模式實現「對擴充開放、對修改封閉」，並結合訂單折扣與 Laravel 實務範例，避免修改既有程式碼造成的回歸風險。

Dec 21, 2025 · 3 min read · blog.bennett1999.com  
Updated Jan 22  
Read the article

-   [#ocp](https://hashnode.com/tag/ocp)
-   [#solid-principles](https://hashnode.com/tag/solid-principles)
-   [#oop](https://hashnode.com/tag/oop)
-   [#backend](https://hashnode.com/tag/backend)
-   [#software-development](https://hashnode.com/tag/software-development)
-   [#laravel](https://hashnode.com/tag/laravel)
-   [#rookiejunior30](https://hashnode.com/tag/rookiejunior30)

## Written by

[Bennett](https://hashnode.com/@bennett1999)

@bennett1999 · Taipei

  
[View profile](https://hashnode.com/@bennett1999)

A good programmer is someone who always looks both ways before crossing a one-way street

一個很忙的工程師，比起寫code更喜歡股票，QQQ買起來，謝謝！

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
