Divya Shiv wrote:Hi,
How different is the object patterns in Kotlin from the Java language implementation? Is there standard built-in patterns in Kotlin ?
Giovanni Montano wrote:
Divya Shiv wrote:Hi,
How different is the object patterns in Kotlin from the Java language implementation? Is there standard built-in patterns in Kotlin ?
Kotlin is 100 per cent compatible with Java, Kotlin generates java code, all the design patterns remain the same. There are some shortcuts, object companion for singletons, by for Delegation patterns, the Observer pattern is changed by RXJava that is 100% applicable from Kotlin, giving you for free lambda expressions, even if runs on java7, also Kotlin has some inbuilt functions that mimicks streams and functional paradigms, but usually people implement RxJava as best practice
Dmitry Jemerov wrote:The difference is that in Kotlin there's a special keyword, , which allows you to create a singleton. In Java, you need to implement it manually.
Several other design patterns become unnecessary in Kotlin - for example, instead of using the Strategy pattern, you can simply use a value of a functional type.