Skip to content

Instantly share code, notes, and snippets.

@alibahaaa
Created February 5, 2023 09:47
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 alibahaaa/9eb78a353074dd97228a66aabe8852e2 to your computer and use it in GitHub Desktop.
Save alibahaaa/9eb78a353074dd97228a66aabe8852e2 to your computer and use it in GitHub Desktop.
interface Component {
fun operation()
}
class ConcreteComponent : Component {
override fun operation() {
// implementation
}
}
abstract class Decorator(private val component: Component) : Component {
override fun operation() {
component.operation()
}
}
class ConcreteDecoratorA(component: Component) : Decorator(component) {
override fun operation() {
super.operation()
// additional behavior
}
}
class ConcreteDecoratorB(component: Component) : Decorator(component) {
override fun operation() {
super.operation()
// additional behavior
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment