composition/

directory
v0.0.0-...-8d8d9e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2016 License: Apache-2.0

README

Interface and Composition Design

Composition goes beyond the mechanics of type embedding and is more than just a paradigm. It is the key for maintaining stability in your software by having the ability to adapt to the data and transformation changes that are coming.

Notes

  • This is much more than the mechanics of type embedding.
  • Declare types and implement workflows with composition in mind.
  • Understand the problem you are trying to solve first. This means understanding the data.
  • The goal is to reduce and minimize cascading changes across your software.
  • Interfaces provide the highest form of composition.

http://golang.org/doc/effective_go.html#embedding
http://www.goinggo.net/2015/09/composition-with-go.html

Design Guidelines

Code Review

Composition and Decoupling

Struct Composition (Go Playground)
Decoupling With Interface (Go Playground)
Interface Composition (Go Playground)
Decoupling With Interface Composition (Go Playground)

Conversion and Assertions

Interface Conversions (Go Playground)
Runtime Type Assertions (Go Playground)

Mocking

Package To Mock (Go Playground)
Client (Go Playground)

Exercises

Exercise 1

Using the template, declare a set of concrete types that implement the set of predefined interface types. Then create values of these types and use them to complete a set of predefined tasks.

Template (Go Playground) | Answer (Go Playground)


All material is licensed under the Apache License Version 2.0, January 2004.

Directories

Path Synopsis
Sample program demonstrating struct composition.
Sample program demonstrating struct composition.
Sample program demonstrating decoupling with interfaces.
Sample program demonstrating decoupling with interfaces.
Sample program demonstrating interface composition.
Sample program demonstrating interface composition.
Sample program demonstrating decoupling with interface composition.
Sample program demonstrating decoupling with interface composition.
Sample program demonstrating when implicit interface conversions are provided by the compiler.
Sample program demonstrating when implicit interface conversions are provided by the compiler.
Sample program demonstrating that type assertions are a runtime and not compile time construct.
Sample program demonstrating that type assertions are a runtime and not compile time construct.
Sample program to show how you can personally mock concrete types when you need to for your own packages or tests.
Sample program to show how you can personally mock concrete types when you need to for your own packages or tests.
pubsub
Package pubsub simulates a package that provides publication/subscription type services.
Package pubsub simulates a package that provides publication/subscription type services.
exercises
exercise1
Using the template, declare a set of concrete types that implement the set of predefined interface types.
Using the template, declare a set of concrete types that implement the set of predefined interface types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL