Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/arthurshafikov/patterns/decorator/solution

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/arthurshafikov/patterns/decorator/solution

  • v0.0.0-20221111082450-091a6adcc560
  • Source
  • Go
  • Socket score

Version published
Created
Source

Decorator Solution

To solve this problem, we'll need to create special classes called decorators (which look like Russian Matryoshka dolls, because they wrap each other) and the Notifier interface which will describe only one method - Send(msg string) error. All the notifiers and decorators must implement this interface.

For example, we want to send a notification via phone + facebook:

  1. We create PhoneNotifier instance
  2. We pass this instance to FacebookDecorator constructor
  3. We execute the job.

The program will call successively the decorator's Send() method, which fires the facebook notification, and then will proceed to the phone notifier's Send() method, which sends the notification via phone.

FAQs

Package last updated on 11 Nov 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc