You are currently viewing Are some of Kotlin’s language features meant to “mirror” common Design Patterns?

Are some of Kotlin’s language features meant to “mirror” common Design Patterns?

Would you agree with the notion that certain features in Kotlin let you implement “similar” behavior to some common Design Patterns without all the boilerplate that comes with manually implementing them? And that while they’re limited compared to the design patterns themselves, they still serve as an excellent substitute for use-cases that aren’t complex enough to code an entire pattern?

Off the top of my head:

Visitor pattern -> Sealed classes with is smart-casting

Builder pattern -> Named arguments and default parameters

(Wrapper) Decorator pattern -> Extension functions

I feel like the Kotlin team intended to provide people easy ways to mimic the behavior of some of these aforementioned patterns, like how Named Args/Default Params gives you the readability that comes with the Builder pattern.

submitted by /u/ED9898A
[link] [comments]