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):
Dependency injection – passing responsibility for dependency to a Client?
I have long standing argue about dependency injection and SOLID principles with my teammate. We both want to make an Exporter, to export data into various formats.
My approach (in PHP):
Is throwing an error in unpredictable subclass-specific circumstances a violation of LSP?
Let’s say I wanted to create a Java List<String>
(see spec) implementation that uses a complex subsystem, such as a database or file system, for its store so that it acts as a persistent collection rather than an in-memory one.
Is throwing an error in unpredictable subclass-specific circumstances a violation of LSP?
Let’s say I wanted to create a Java List<String>
(see spec) implementation that uses a complex subsystem, such as a database or file system, for its store so that it acts as a persistent collection rather than an in-memory one.
Liskov principle: violation by type-hinting
According to the Liskov principle, a construction like the one below is invalid, as it strengthens a pre-condition.
Liskov principle: violation by type-hinting
According to the Liskov principle, a construction like the one below is invalid, as it strengthens a pre-condition.
Liskov principle: violation by type-hinting
According to the Liskov principle, a construction like the one below is invalid, as it strengthens a pre-condition.
Single responsibility vs procedural programming [duplicate]
This question already has answers here: Clarify the Single Responsibility Principle (14 answers) Closed 9 years ago. Single responsibility (from SOLID) is like making me create classes with only one public method. But if it’s so, it would be possible use static methods, and go back to procedural programming. What’s the difference? object-oriented solid single-responsibility […]
Single responsibility vs procedural programming [duplicate]
This question already has answers here: Clarify the Single Responsibility Principle (14 answers) Closed 9 years ago. Single responsibility (from SOLID) is like making me create classes with only one public method. But if it’s so, it would be possible use static methods, and go back to procedural programming. What’s the difference? object-oriented solid single-responsibility […]
Single responsibility vs procedural programming [duplicate]
This question already has answers here: Clarify the Single Responsibility Principle (14 answers) Closed 9 years ago. Single responsibility (from SOLID) is like making me create classes with only one public method. But if it’s so, it would be possible use static methods, and go back to procedural programming. What’s the difference? object-oriented solid single-responsibility […]