Skip to content

[Kotlin] シングルトンパターンでは object を使用してみる #6

Description

@and-tsumuraya

あなたの改善要求はどんな問題に関連していますか?
シングルトンパターンの実装は改善が出来そうです。

解決目的
シングルトンパターンでは object を使用してみる

検討した代替案
Kotlinではシングルトンパターンを容易に使うことが出来る オブジェクトの宣言 があるので、それを使用してみるのもいいかもしれません。

https://dogwood008.github.io/kotlin-web-site-ja/docs/reference/object-declarations.html#%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%81%AE%E5%AE%A3%E8%A8%80

ReposRemoteDataSourceobject を用いることでよりシンプルに(Kotlinっぽく)出来るかと思いました。
https://github.com/RyoShimizu0215/githubrepos/blob/master/app/src/main/java/com/example/githubrepos/data/source/remote/ReposRemoteDataSource.kt#L15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions