---
title: "Comment by Edinson Oscar Luna Penia on \"Solid Software Design: Applying the Open/Closed Principle (OCP) in Java\" | Hashnode"
description: "This article clearly explains the Open/Closed Principle (OCP) and demonstrates it with a practical Java example of discount strategies. By adhering to OCP, the"
url: "https://hashnode.com/posts/solid-software-design-applying-the-openclosed-principle-ocp-in-java/67e6d8c3eb2e266310dcafe5/comment/68112a602c947ef92b159140"
---

[Discussion](https://hashnode.com/posts/solid-software-design-applying-the-openclosed-principle-ocp-in-java/67e6d8c3eb2e266310dcafe5)

Comment [Solid Software Design: Applying the Open/Closed Principle (OCP) in Java](https://hashnode.com/posts/solid-software-design-applying-the-openclosed-principle-ocp-in-java/67e6d8c3eb2e266310dcafe5)

[Edinson Oscar Luna Penia](https://hashnode.com/@Edinson24)

[Apr 29, 2025](https://hashnode.com/posts/solid-software-design-applying-the-openclosed-principle-ocp-in-java/67e6d8c3eb2e266310dcafe5/comment/68112a602c947ef92b159140)

This article clearly explains the Open/Closed Principle (OCP) and demonstrates it with a practical Java example of discount strategies. By adhering to OCP, the system allows new discount types to be added without modifying existing code, which enhances flexibility and maintainability. The inclusion of a GitHub Actions automation workflow adds an extra layer of practicality by ensuring the code is consistently tested with every change.
