Learning Functional Programming in Go
上QQ阅读APP看书,第一时间看更新

Adding Functionality with Decoration

In this chapter, we'll continue to address this remark: If you like design patterns, use Java, not Go. We'll do so with the help of the decorator and strategy patterns.

Our goal in this chapter is to understand:

  • Go's Reader and Writer interfaces
  • Why designing using the interface composition is better than type hierarchy design
  • How to design with and implement the Decorator Pattern
  • Inversion of Control (IoC) by implementing an IoC framework
  • How to set up a request timeout using a proxy 
  • How to apply the Strategy Pattern when load balancing requests
  • How to understand easy-metrics graphs
  • How to implement a simple yet effective logger using standard library interfaces
  • How to enrich HTTP requests with logging using dependency injection
  • How to use channels to control the flow of events in a concurrent program
  • A better way to extend our application's functionality