Created
June 6, 2025 08:28
-
-
Save acious/6a8f2c5bf5636d849e9421852c149d03 to your computer and use it in GitHub Desktop.
C.C - Domain Layer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // file: domain/User.kt | |
| /** | |
| * 순수한 비즈니스 모델 (Entity). | |
| * 앱의 핵심 도메인이며, 데이터베이스나 UI에 대한 정보를 전혀 모릅니다. | |
| */ | |
| data class User( | |
| val id: String, | |
| val name: String, | |
| val email: String, | |
| val birthYear: Int | |
| ) | |
| // file: domain/UserRepository.kt | |
| /** | |
| * 데이터 계층에 의해 구현될 인터페이스(계약). | |
| * UseCase는 이 인터페이스에만 의존합니다. | |
| */ | |
| interface UserRepository { | |
| suspend fun getUser(id: String): Result<User> | |
| } | |
| // file: domain/GetUserUseCase.kt | |
| /** | |
| * 애플리케이션의 특정 비즈니스 로직을 처리하는 UseCase. | |
| */ | |
| class GetUserUseCase(private val userRepository: UserRepository) { | |
| suspend operator fun invoke(id: String): Result<User> { | |
| return userRepository.getUser(id) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment