Created
September 19, 2021 04:31
-
-
Save alfianyusufabdullah/82fe933474435ca9db396e2ece8b15c7 to your computer and use it in GitHub Desktop.
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
class Repository(){ | |
fun getData(): String { | |
return dataSource() | |
} | |
fun dataSource(): String { | |
return "data from datasource!" | |
} | |
} | |
fun main() { | |
val repo = Repository() | |
println(repo.dataSource()) | |
} |
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
class DataSource(){ | |
fun getData(): String { | |
return "SRP - data from datasource!" | |
} | |
} | |
class Repository(private val datasource: DataSource){ | |
fun getData(): String { | |
return datasource.getData() | |
} | |
} | |
fun main() { | |
val datasource = DataSource() | |
val repo = Repository(datasource) | |
println(repo.getData()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment