Implements efficient Kotlin delegation patterns to reduce boilerplate and improve code reusability in Android and JVM projects.
This skill provides comprehensive guidance on Kotlin's delegation mechanisms, including built-in property delegates like lazy, observable, and vetoable, as well as interface delegation using the 'by' keyword. It offers production-ready patterns for Android development—such as ViewBinding and SharedPreferences delegates—and custom delegate implementations like StateFlow and Singleton patterns. By leveraging these patterns, developers can create cleaner, more maintainable codebases while adhering to the principle of composition over inheritance, ensuring that cross-cutting concerns are handled consistently throughout the application.
主な機能
01Custom property delegates for SharedPreferences, StateFlow, and Singletons
021 GitHub stars
03Built-in property delegates including lazy, observable, and vetoable
04Android-specific patterns like memory-safe ViewBinding delegation
05Map-based delegation for handling dynamic JSON-like data structures
06Interface delegation for composition over inheritance architectures
ユースケース
01Enforcing property validation and state change observation via delegation
02Implementing thread-safe lazy initialization for resource-heavy objects
03Reducing boilerplate code in Android ViewModels, Fragments, and Activities