🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

github.com/smaxwellstewart/golang-decorator-pattern

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/smaxwellstewart/golang-decorator-pattern

v0.0.0-20160303041519-76e8497672e2
Source
Go
Version published
Created
Source

golang-decorator-pattern

This is an example of the decorator pattern in golang. It is very useful when a method has many orthogonal concerns.

What does 'many orthogonal concerns' mean? Say we wanna do a http request, pretty simple right. But what if we also need to perform some logging of the request as well as add the requested action to an audit trail, notify another service of this request, increase the request count in a rate limiter, etc. None of these concerns are related, other than that we wanna do all of them whenever we call our method. This is where the decorator pattern really helps.

By implementing the decorator pattern we subscribe to the open-closed principal. Our method is open to future extension but closed to future modification. There's a lot of groovy benefits to obeying the open-closed pricniple.

For more useful info see: https://www.youtube.com/watch?v=xyDkyFjzFVc

FAQs

Package last updated on 03 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts