본문 바로가기
반응형

IT개발/Kotlin4

Kotlin design pattern https://www.raywenderlich.com/470-common-design-patterns-for-android-with-kotlin Common Design Patterns for Android with Kotlin Discover how to make your Android code cleaner and easier to understand with these common design patterns for Android apps. Future you will appreciate it! www.raywenderlich.com 생성 - Builder - Dependency Injection - Singleton 구조 - Adapter - Facade 행위 - Command - Observer.. 2020. 1. 13.
Kotlin의 null 처리 https://kotlinlang.org/docs/reference/null-safety.html https://developer.android.com/kotlin/common-patterns?hl=ko 상호 운용성 (Interoperability) 코틀린이 자바의 라이브러리를 사용하는 경우가 많기 때문에, 널 처리에 대하여 주의 하여야 한다. 자바의 매개변수를 코틀린에서 참조 할 수 있도록 @Nullable, @NonNull 을 추가해 주는 것이 좋다. val param : String? !! (not-null assertion operator) param이 널일 경우 KotlinNullPointerException 이 발생 ? 를 사용하면, 다음 구문에 널 전달, Elivs 연산자를 사용해서 처리 가.. 2020. 1. 9.
코루틴 https://kotlinlang.org/docs/reference/coroutines/coroutines-guide.html Coroutines Guide - Kotlin Programming Language kotlinlang.org 코루틴은 동시 실행 설계 패턴이다. 코틀린 1.3에 추가 되었음. 기본 스레드를 차단하여 앱이 정지될 수 있는 장기 실행 작업을 관리합니다. 기본 스레드에서 네트워크 또는 디스크 작업을 안전하게 호출하는 기능을 제공 Coroutine : cooperative routine kotlinx.coroutines.* 비동기 스레드 처리 스레드가 특정 "정지 지점"에서 코루틴 실행을 중지하고 다른 작업을 수행 할 수 있다는 것이다. 나중에 코루틴을 다시 시작하거나 다른 스레드가 .. 2020. 1. 7.
Kotlin 유용한 함수 조건 확인 함수 특정 값의 일치 여부 확인 : check, require 인자의 값(true/false)에 따른 처리 (false일 때에 대한 처리용) false일때 exception 발생 flase일때 exception 발생 및 메세지 출력 (lazyMessage) fun check(value: Boolean) (throws IllegalStateException) fun check(value: Booelan, lazyMessage: () -> Any) (throws IllegalStateException) fun checkNotNull(value: T?) : T (throws IllegalStateException) fun checkNotNull(value: T?, lazyMessage: () -> .. 2019. 12. 19.
반응형