Decoupling Interface from Implementation

With JavaScript, everything is asynchronous (almost)

  • event handler name – interface
  • callback – implementation

Examples: jQuery, Node.js EventEmitter, Go has callbacks too

With Go, interfaces are satisfied implicitly

  • From Go Bootcamp book,

There is no explicit declaration of intent. Implicit interfaces decouple implementation packages from the packages that define the interfaces: neither depends on the other.

Message-based systems

  • Publisher – puts the message on a queue or channel (an identifier acts as the interface)
  • Subscriber – decodes the identifier, then apply logic to it (implementation)
Advertisements

Subjectivity aside, leave a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s