+1
Under review
Could somebody explain me how to use Bridge with Abstrac Factory?
The Bridge article says:
"You can use Abstract Factory along with Bridge. This pairing is useful when some abstractions defined by Bridge can only work with specific implementations. In this case, Abstract Factory can encapsulate these relations and hide the complexity from the client code."
But I can't really understand what "specific implementations" are. Does that mean some variation of products? If so, would it be better to get such product from the constructor rather than Abstract Factory? Could somebody give an example of using Bridge with Abstrac Factory?
Customer support service by UserEcho
Hi!
Suppose you have a Bridge hierarchy like this:
Abstraction: BasicFileSystem → VersionControlFileSystem
Implementations: Fat, NTFS, APFS
One of the abstractions (VersionControlFileSystem) can only work with a specific implementation (NTFS, APFS).
Instead of requiring client to know about this implication when instantiating Abstractions & Implementations, you could provide abstract factory to create necessary classes (and maybe even handle errors when non-existent pairs are requested). Below is a pseudocode:
Thank you for explanation. I think this should be included in article using some kind of footnote.