Skip to content

Instantly share code, notes, and snippets.

@alfianyusufabdullah
Created September 19, 2021 04:31
Show Gist options
  • Save alfianyusufabdullah/82fe933474435ca9db396e2ece8b15c7 to your computer and use it in GitHub Desktop.
Save alfianyusufabdullah/82fe933474435ca9db396e2ece8b15c7 to your computer and use it in GitHub Desktop.
class Repository(){
fun getData(): String {
return dataSource()
}
fun dataSource(): String {
return "data from datasource!"
}
}
fun main() {
val repo = Repository()
println(repo.dataSource())
}
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