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


    Android App Developer

    sipgate GmbH
    Düsseldorf, Remote
    • Full Time
    apply now

    Developer (m/w/d) Backend/ Mobile

    Payback GmbH
    Cologne, Germany
    • Full Time
    apply now

    Senior Android Developer (Remote)

    Komoot
    Europe
    • Full Time
    apply now
Load more listings

OUR VIDEO RECOMMENDATION

, ,

Automated migration of Android apps to Bazel build system

Migrating large projects that consist of hundreds or thousands of modules and being maintained by a large team, from Gradle to Bazel might be challenging. I would like to discuss the process of automation of…
Watch Video

Automated migration of Android apps to Bazel build system

Pavlo Stavytskyi
Software Engineer
Lyft

Automated migration of Android apps to Bazel build system

Pavlo Stavytskyi
Software Engineer
Lyft

Automated migration of Android apps to Bazel build system

Pavlo Stavytskyi
Software Engineer
Lyft

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

Leave a Reply

Your email address will not be published.

Fill out this field
Fill out this field
Please enter a valid email address.

Menu