Last active
February 11, 2021 07:09
-
-
Save jordanterry/514b896254a1b3b3b3ca5c936e9f9697 to your computer and use it in GitHub Desktop.
Abstractions
This file contains 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
data class Document( | |
val data: Byte[] | |
} | |
interface ExportDocument { | |
fun export(document: Document) | |
} | |
class PngExportDocument : ExportDocument { | |
override fun export(document: Document) = TODO("Export as Png") | |
} | |
class JpgExportDocument : ExportDocument { | |
override fun export(document: Document) = TODO("Export as Jpg") | |
} | |
class Editor( | |
private val exportDocument: ExportDocument | |
) { | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment