|10 september 2019||Day of the programmer||Jönköping||Tell, don´t ask!|
Tell, don’t ask!
Length: 15 minutes
Languages: Swedish, English
The definition of “S” (Single Responsibility Principle) in the SOLID principle, states that “A class should have only one reason to change”. Small changes to requirement shouldn’t lead to many changes in other parts of code.
A class for a domain object can be more than just a data carrier. The domain objects should be responsible for its own properties.
To get there you can use the “Tell, don’t ask” principle. With this pattern, we can make our code more testable and encapsulate functionality where it belongs.