Timeline for Builder pattern inside interface. Bad design decision?
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 8, 2022 at 5:16 | comment | added | kiwicomb123 | @FerdinandBeyer After a few years of building, ( and reading clean architecture by Bob Martin ) I totally get decoupling architectural layers. I don't know I survived code bases before knowing this. | |
Nov 4, 2021 at 9:21 | comment | added | Alessio Gaeta | Another example is when you have persisted entities in a schema-less storage: you will usually have only one implementation, but having an interface allows to refactor it without being forced to migrate all your persisted data at once, in a coordinated way with the model change. | |
May 23, 2020 at 14:15 | comment | added | Ferdinand Beyer | A good example is when you separate your domain logic from the UI. You will create an interface in your domain layer to send data to display to the user in the UI, that will be implemented in the UI layer. You do that to introduce an architectural boundary: UI knows (depends on) the domain, but not vice versa. It does not matter at all how many implementations there will be. | |
May 13, 2020 at 22:19 | comment | added | kiwicomb123 | Why do you want to decouple architectural layers? So that you can change one without effecting the other. Would you change an existing one or creating a new one? If you change an existing one, you are modifying existing code and breaking the open closed principle. So you have to create a new one. So you have a new implementation. (2 implementations for the same interface) So yes, the number of implementations is directly related to the reasoning for interfaces. If there is never going to be another implementation, then there is no reason for the abstraction. Avoid speculative design. | |
May 13, 2020 at 19:00 | comment | added | Ferdinand Beyer | You made some valid points, but "you only need an interface when you will have more than one implementation" is not general good advice. The Person example here seems artificial, but usually you want to introduce interfaces to decouple architectural layers, no matter how many implementations will exist. | |
May 24, 2017 at 18:40 | review | Late answers | |||
May 25, 2017 at 14:03 | |||||
May 24, 2017 at 18:24 | history | answered | kiwicomb123 | CC BY-SA 3.0 |