Relative Content

Tag Archive for open-closed-principle

Trade-offs between applying the open-closed principle and type safety

There’s lots of questions about the open-closed principle here, but none that I found satisfied this particular problem. At $job, I’m teaching my team Rust, but I believe the nature of this question extends beyond Rust. We have a training problem that we use to kick the tires on new ideas, because we can all imagine a few canonical solutions to it. One small aspect of this problem is that an embedded target needs to communicate with a host PC over a serial port. Naturally, I used Rust’s famous enums to describe the protocol (domain terms have been erased from the example):

Understanding Bob Martin’s Closed For Modification Explanation

“Closed for modification.” Extending the behavior of a module does not
result in changes to the source or binary code of the module. The
binary executable version of the module, whether in a linkable
library, a DLL, or a Java .jar, remains untouched.

Understanding Bob Martin’s Closed For Modification Explanation

“Closed for modification.” Extending the behavior of a module does not
result in changes to the source or binary code of the module. The
binary executable version of the module, whether in a linkable
library, a DLL, or a Java .jar, remains untouched.

Understanding Bob Martin’s Closed For Modification Explanation

“Closed for modification.” Extending the behavior of a module does not
result in changes to the source or binary code of the module. The
binary executable version of the module, whether in a linkable
library, a DLL, or a Java .jar, remains untouched.