Posts by Willian • 71 points
2 posts
-
4
votes1
answer66
viewsQ: Follow the OCP principle or use "instanceof"
The OCP principle preaches: "open to extension, but closed to alteration". To achieve this we need to abstract, because with an abstraction we can extend without needing to change the one that uses…
-
3
votes2
answers82
viewsQ: How to instantiate Strategy objects
Consider the basic implementation of the standard Strategy. public class Context{ private Strategy strategy; } public interface Strategy{ void algoritmo(); } public class ConcreteStrategyA…