composition/

directory
v0.0.0-...-ff8a63e Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2015 License: Apache-2.0

README

Composition

Composition goes beyond the mechanics of type embedding. It's a design pattern we can leverage in Go to build larger programs from smaller parts. These smaller parts come from the declaration and implementation of types that have a single focus. Programs that are architected with composition in mind have a better chance to grow and adapt to changes.

Notes

  • Declare types and behavior with composition in mind.
  • Composition is like building software with lego blocks.
  • This is much more than the mechanics of type embedding.

http://golang.org/doc/effective_go.html#embedding

http://www.goinggo.net/2015/09/composition-with-go.html

Code Review

Composition I (Go Playground)

Composition II (Go Playground)

Exercises

Exercise 1

Part A Follow the guided comments to:

Part B Declare a sysadmin type that implements the administrator interface.

Part C Declare a programmer type that implements the developer interface.

Part D Declare a company type that embeds both an administrator and a developer.

Part E Create a sysadmin, programmers, and a company which are available for hire, and use them to complete some 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 composition through embedding.
Sample program demonstrating composition through embedding.
Sample program demonstrating composition through embedding.
Sample program demonstrating composition through embedding.
exercises
exercise1
Follow the guided comments to: Declare a sysadmin type that implements the administrator interface.
Follow the guided comments to: Declare a sysadmin type that implements the administrator interface.
template1
Follow the guided comments to: Declare a sysadmin type that implements the administrator interface.
Follow the guided comments to: Declare a sysadmin type that implements the administrator interface.

Jump to

Keyboard shortcuts

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