Closed mattfbacon closed 3 years ago
The point is that you may want to implement more complex methods other than addAndSave that use the dataBase interface. addAndSave is just an example.
And in those cases you can add more abstract methods without an issue.
This defeats the purpose of having a separate hierarchy for abstraction and implementation. Also, the more complex methods could be using non-database related objects and would be impossible to add as abstract methods.
This defeats the purpose of having a separate hierarchy for abstraction and implementation.
Quite the opposite: the fact that you can make them abstract methods completely obviates this "parallel hierarchy".
Also, the more complex methods could be using non-database related objects and would be impossible to add as abstract methods.
First of all, if you want to demonstrate that then why don't you? Second of all, they would not be impossible to add as abstract methods by any means. Just take the other objects as parameters. That said, if you were making an abstraction that glues together multiple interfaces (i.e., not just DB), it would make sense to have this "Abstraction" class, but if that was what you're going for, you should probably actually add the other interfaces, and demonstrate how the abstraction joins them.
Lol, well exactly it obviates the parallel hierarchy which doesn't make it the bridge pattern. But you are right, I will come up with a better example.
If you make
dataBase
an abstract class and implementaddAndSave
using the abstract methods, this would not be an issue at all.