Blog Infos
Author
Published
Topics
Published
Topics
Are you sure “reducing coupling” is what you‘re after?

Photo by Theo Crazzolara https://unsplash.com/photos/k8mRwVA4MpA

The good
Polymorphism
interface Message {
val timestamp: DateTime
}
class TextMessage(
val text: String,
override val timestamp: DateTime
) : Message
class ImgMessage(
val imgUri: URI,
override val timestamp: DateTime
) : Message
Multiple inheritance
interface ToastShowable {
fun showToast(context: Context, text: String) = ...
}
class MainActivity : ComponentActivity(), ToastShowable {
override fun onCreate(savedInstanceState: Bundle?) {
//...
showToast(this, "Le toast")
}
}

You can do something similar on iOS by leveraging protocol extensions.

protocol Shakeable {
func shake()
}
extension Shakeable where Self: UIView {
func shake() {
UIView.animate(...
}
}
Boundaries between layers

Simplified clean architecture schema

Job Offers

Job Offers

There are currently no vacancies.

OUR VIDEO RECOMMENDATION

, ,

Kobweb:Creating websites in Kotlin leveraging Compose HTML

Kobweb is a Kotlin web framework that aims to make web development enjoyable by building on top of Compose HTML and drawing inspiration from Jetpack Compose.
Watch Video

Kobweb:Creating websites in Kotlin leveraging Compose HTML

David Herman
Ex-Googler, author of Kobweb

Kobweb:Creating websites in Kotlin leveraging Compose HTML

David Herman
Ex-Googler, author o ...

Kobweb:Creating websites in Kotlin leveraging Compose HTML

David Herman
Ex-Googler, author of Kob ...

Jobs

Clean architecture is very widespread in mobile development, but one thing that is often misunderstood is that the data layer is outer to the domain layer. Business logic doesn’t need to know how the data is delivered, it should only define its inputs, usually via the means of a Repository interface, which can be implemented by the data layer.

 

In clean architecture, the domain layer defines Repository interface which is implemented by data layer

 

The bad
Test Doubles
protocol Grinder {
func grind(_ coffee: Coffee)
}
class GrinderMock: Grinder {
private(set) var timesUsed: Int = 0
func grind(_ coffee: Coffee) {
timesUsed += 1
}
}
class CoffeeMakerTest: XCTestCase {
func test_grinder_used_once_when_coffee_made() {
let grinder = GrinderMock()
let sut = CoffeeMaker(grinder: grinder)
sut.makeCoffee()
XCTAssertEqual(grinder.timesUsed, 1)
}
}
Callbacks
public interface OnClickListener {
void onClick(View v);
}
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//handle click
}
});

This is no longer idiomatic in Kotlin. Functions are types in Kotlin, so you can easily pass them around as variables

class ListAdapter(val itemClickListener : () -> Unit) { ...
fun interface OnClickListener { fun invoke() }
The ugly
“Because I can easily replace it with another implementation”

YOU MAY BE INTERESTED IN

YOU MAY BE INTERESTED IN

blog
It’s one of the common UX across apps to provide swipe to dismiss so…
READ MORE
blog
Hi, today I come to you with a quick tip on how to update…
READ MORE
blog
Automation is a key point of Software Testing once it make possible to reproduce…
READ MORE
blog
Drag and Drop reordering in Recyclerview can be achieved with ItemTouchHelper (checkout implementation reference).…
READ MORE
Menu