mardi 24 mars 2015

Understanding 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.


Hall, Gary McLean (2014-10-10). Adaptive Code via C#: Agile coding with design patterns and SOLID principles (Developer Reference) (p. 208). Pearson Education. Kindle Edition.



In Adaptive Code via C#, the author quotes Robert C. Martin's explanation for Closed for Modification. How should we understand "The binary executable version of the module, whether in a linkable library, a DLL, or a Java .jar, remains untouched."


We can use staircase patterns for dependency tree in which interfaces and implementations are in different assemblies, and we can extend implementations in different assemblies, but not sure how reasonable this is. I don't think copying over the rest of the behavior to the new assembly makes sense. Can someone please visualize this explanation with an example.


Aucun commentaire:

Enregistrer un commentaire