Android Chess 016: Using Kotlin interface to decouple classes ChessView and MainActivity

Опубликовано: 27 Март 2026
на канале: Golden Thumb | Stories & Code
1,142
21

This is an important design decision. Classes working together should be loosely coupled. We created an interface named ChessDelegate providing a service of pieceAt(col: Int, row: Int), which returns a nullable object of ChessPiece. In an interface, functions have only signature without body.

interface ChessDelegate {
fun pieceAt(col: Int, row: Int) : ChessPiece?
}

GitHub repo:
https://github.com/zhijunsheng/chess-...