mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-22 04:36:02 +03:00
organize structural patterns
This commit is contained in:
parent
560478d5cf
commit
b3ac04909d
@ -38,10 +38,10 @@ A curated collection of idiomatic design & application patterns for Go language.
|
|||||||
|:-------:|:----------- |:------:|
|
|:-------:|:----------- |:------:|
|
||||||
| [Bridge](/structural/bridge/main.go) | Decouples an interface from its implementation so that the two can vary independently | ✔ |
|
| [Bridge](/structural/bridge/main.go) | Decouples an interface from its implementation so that the two can vary independently | ✔ |
|
||||||
| [Composite](/structural/composite/main.go) | Encapsulates and provides access to a number of different objects | ✔ |
|
| [Composite](/structural/composite/main.go) | Encapsulates and provides access to a number of different objects | ✔ |
|
||||||
| [Decorator](/structural/decorator.md) | Adds behavior to an object, statically or dynamically | ✔ |
|
| [Decorator](/structural/decorator/decorator.md) | Adds behavior to an object, statically or dynamically | ✔ |
|
||||||
| [Facade](/structural/facade/main.go) | Uses one type as an API to a number of others | ✔ |
|
| [Facade](/structural/facade/main.go) | Uses one type as an API to a number of others | ✔ |
|
||||||
| [Flyweight](/structural/flyweight/main.go) | Reuses existing instances of objects with similar/identical state to minimize resource usage | ✔ |
|
| [Flyweight](/structural/flyweight/main.go) | Reuses existing instances of objects with similar/identical state to minimize resource usage | ✔ |
|
||||||
| [Proxy](/structural/proxy.md) | Provides a surrogate for an object to control it's actions | ✔ |
|
| [Proxy](/structural/decorator/proxy.md) | Provides a surrogate for an object to control it's actions | ✔ |
|
||||||
|
|
||||||
## Behavioral Patterns
|
## Behavioral Patterns
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "log"
|
||||||
|
|
||||||
type Object func(int) int
|
type Object func(int) int
|
||||||
|
|
||||||
func LogDecorate(fn Object) Object {
|
func LogDecorate(fn Object) Object {
|
||||||
@ -18,11 +20,10 @@ func Double(n int) int {
|
|||||||
return n * 2
|
return n * 2
|
||||||
}
|
}
|
||||||
|
|
||||||
func main(){
|
func main() {
|
||||||
f := LogDecorate(Double)
|
f := LogDecorate(Double)
|
||||||
f(5)
|
f(5)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Starting execution with the integer 5
|
// Starting execution with the integer 5
|
||||||
// Execution is completed with the result 10
|
// Execution is completed with the result 10
|
Loading…
Reference in New Issue
Block a user