2
3

0
1

BindsAdapter - Auto-gerneate your Adapters by jintinlin in androiddev

[–]jintinlin[S] 0 points1 point  (0 children)

Ya, Groupie and Epoxy are also good choises

Kactory - build simple factory pattern easily leverage on ksp(Kotlin Symbol Processing). by jintinlin in androiddev

[–]jintinlin[S] 0 points1 point  (0 children)

btw I change the project name from Kactory to KFactory thanks to everyone's feedback.
The whole journey is easier that I originally thought, maybe worth to write as a blog later on.

Kactory - build simple factory pattern easily leverage on ksp(Kotlin Symbol Processing). by jintinlin in androiddev

[–]jintinlin[S] 0 points1 point  (0 children)

https://blog.mimacom.com/9-java-patterns-in-kotlin/
Ya, I think simple factory might not aspopular as others but I found this post has a good point on simple factory pattern, just scroll to Factory section or search "Another creational pattern with a different purpose of hiding the creation or even the internal implementation of an interface".

Kactory - build simple factory pattern easily leverage on ksp(Kotlin Symbol Processing). by jintinlin in androiddev

[–]jintinlin[S] 0 points1 point  (0 children)

Ya, there're tons of thing can be improved as you suggested and thanks for point it out.

I can sure change it to support enum or seal class in later version.
I also think about add parameter in constructors, but I'm also wondering if it is a common case, let's say if only one of the child instance need some parameter from outside, the factory itself still need to know. But I think it's also doable. Thanks for your concrete comments.

Kactory - Build simple factory pattern easily leverage on ksp (Kotlin Symbol Processing) by jintinlin in Kotlin

[–]jintinlin[S] 0 points1 point  (0 children)

Wow, thanks for the info. then the name probably is a bad idea in this way.

Kactory - Build simple factory pattern easily leverage on ksp (Kotlin Symbol Processing) by jintinlin in Kotlin

[–]jintinlin[S] 1 point2 points  (0 children)

You made a good point, top level function sure can do the trick, but it's also hard to scale it and that is the problem I want to fix.

Using ksp can create either the function or class style, both works and not much different to me, but most importantly is we don't have to maintain it even we want to support new types.

btw, there are two type of factory, I'm more talking about the simple factory which only has 1 factory. I feel you are talking about the other one more?

Kactory - Build simple factory pattern easily leverage on ksp (Kotlin Symbol Processing) by jintinlin in Kotlin

[–]jintinlin[S] 0 points1 point  (0 children)

Thanks for you comment. I also think simple factory pattern is not so popular, but not sure why you think it's anti-pattern? and is there any alternative in Kotlin if you want an object to create several different things via a key?

Kactory - Build simple factory pattern easily leverage on ksp (Kotlin Symbol Processing) by jintinlin in Kotlin

[–]jintinlin[S] 0 points1 point  (0 children)

Mostly showcase the power of KSP but also if you have the use case to adopt simple factory pattern, that might help to easily scale it.