dmitrikudrenko / BetterAdapters

Sample for https://medium.com/@dpreussler/writing-better-adapters-1b09758407d2
45 stars 17 forks source link

Simplifying usage of TypesFactory class #3

Open yeduRaghav opened 6 years ago

yeduRaghav commented 6 years ago

Hi, First of all thank you for putting up the sample. I have been going through your example and I have a feeling that the TypesFactoryImpl class could be a regular factory, with static factory methods. Therefore, it's instance don't need to be held by Adapter.

Unless I missed a big point

dmitrikudrenko commented 6 years ago

Hi, @yeduRaghav Yeah, you are right. It is possible to remove TypesFactory, make TypesFactoryImpl Kt-object and use it directly. But according to dependency inversion principle it would be better to use interface+implementation and send it to adapter (in the sample I create it, but I should use TypesFactory in adapter constructor).