Skip to content

Instantly share code, notes, and snippets.

@jordanterry
Last active February 11, 2021 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordanterry/514b896254a1b3b3b3ca5c936e9f9697 to your computer and use it in GitHub Desktop.
Save jordanterry/514b896254a1b3b3b3ca5c936e9f9697 to your computer and use it in GitHub Desktop.
Abstractions
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