kotlin-fundamentals
Master Kotlin syntax, OOP principles, SOLID practices, functional programming, and data structures. Use when writing Kotlin code or designing class hierarchies.
When & Why to Use This Skill
This Claude skill provides comprehensive expertise in Kotlin programming, ranging from core syntax and null safety to advanced architectural patterns. It empowers users to generate clean, idiomatic, and efficient Kotlin code by leveraging Object-Oriented Programming (OOP) principles, SOLID practices, and functional programming constructs. Designed for both Android and JVM environments, it ensures high-quality software development through robust data structures and modern concurrency models like Coroutines.
Use Cases
- Case 1: Generating idiomatic Kotlin code for Android applications, utilizing null safety, extension functions, and scope functions to reduce boilerplate.
- Case 2: Refactoring legacy codebases to adhere to SOLID principles and OOP best practices, improving long-term maintainability and scalability.
- Case 3: Designing complex class hierarchies and implementing efficient data structures for high-performance backend services.
- Case 4: Implementing asynchronous programming logic using Kotlin Coroutines to manage background tasks and improve UI responsiveness.
- Case 5: Applying functional programming patterns such as higher-order functions and collection transformations to create concise and readable logic.
| name | fundamentals |
|---|---|
| description | Master Kotlin syntax, OOP principles, SOLID practices, functional programming, and data structures. |
| version | "2.0.0" |
| sasmp_version | "1.3.0" |
| bonded_agent | 01-android-fundamentals |
| bond_type | PRIMARY_BOND |
| atomic | true |
| single_responsibility | Kotlin & OOP fundamentals |
| type | string |
| enum | [kotlin, oop, solid, functional, collections] |
| required | false |
| max_attempts | 2 |
| backoff | exponential |
| on_failure | return_basic_example |
| level | info |
| include | [query, response_time, errors] |
Kotlin Fundamentals Skill
Quick Start
// Variables
val immutable = "constant"
var mutable = "variable"
// Functions
fun greet(name: String): String = "Hello, $name"
// Classes
data class User(val id: Int, val name: String)
// Null safety
val user: User? = null
user?.name // safe call
user?.name ?: "Unknown" // elvis operator
Key Concepts
Null Safety
?for nullable types!!for non-null assertion (avoid)?:elvis operator for defaults?.let { }for null-safe blocks
Extension Functions
fun String.isValidEmail(): Boolean = contains("@")
val valid = "user@example.com".isValidEmail()
Scope Functions
apply: Configure objectlet: Transformrun: Execute with contextwith: Receiver operationsalso: Side effects
Coroutines
viewModelScope.launch {
val data = withContext(Dispatchers.IO) {
fetchData()
}
}
SOLID Principles Summary
- SRP: One responsibility per class
- OCP: Open for extension, closed for modification
- LSP: Substitutable subtypes
- ISP: Specific interfaces
- DIP: Depend on abstractions