Skip to content

dotnet core example showing a practical usage of the Open-Closed principle

Notifications You must be signed in to change notification settings

cjstremick/OpenClosedExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenClosedExample

Demonstrate how a programmer might use typical OOP to solve concrete problems with composable code.

To test the code, run it and try some of these url's:

  • /api/move/train/10
  • /api/move/jet/2
  • /api/move/hippo/13

New "MoveProcessor" implementations can be added to the system without modifying any code. This makes the code Closed to modification and Open to extension.

To extend the program to add a new behavior, create a new concrete implementation and then register it in your IoC container to make the type available.

There are several benefits to using this sort of pattern over other alternatives:

  1. Your business logic is contained is a small, specific, easy-to-test unit.
  2. You can add new capabilities without affecting other code, perhaps introducing unintended side-effects.
  3. Maintenance is much easier since the the surface area to debug is significantly smaller.

About

dotnet core example showing a practical usage of the Open-Closed principle

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages