Hi everyone. <https://github.com/gastsail/Cocktail...
# announcements
a
Hi everyone. https://github.com/gastsail/CocktailApp/tree/master/app/src/main/java/com/g/tragosapp/domain According to this repo, the developer extract the interface and the actual implementation to different files. Does this approach has any name?
v
Good design? :-D
"Coding to interfaces" is one of the phrases describing it partly
☝️ 2
You can easily swap the implementations if you just used the interfaces, like
List
vs.
ArrayList
,
LinkedList
, ...
z
I don't know if there's a name for specifically putting the interface and implementation in different files. But I've heard the pattern of logically separating the code called simply "the interface/impl pattern". But it also relates to other patterns such as dependency inversion.
a
I see. Thank you @Vampire @Zach Klippenstein (he/him) [MOD]
@Vampire not sure if this is a good design or not. But I heard from other it helps on creating test case.
v
It can, as I said. If you stick to interfaces, you can easily swap implementations and then for example give a mock instead that implements the same interface.
a
@Zach Klippenstein (he/him) [MOD] I found the name of this pattern.
Bridge pattern
. https://en.wikipedia.org/wiki/Bridge_pattern
v
Not really. Did you actually read the book, or the wiki page?
a
@Vampire yeah. I actually read the short description and went through the SO to understand it. Am I missing something?
v
Yes, read it again. :-) The wiki article explains it better than I could.