Book description
Learn idiomatic, efficient, clean, and extensible Go design and concurrency patterns by using TDD
About This Book
- A highly practical guide filled with numerous examples unleashing the power of design patterns with Go.
- Discover an introduction of the CSP concurrency model by explaining GoRoutines and channels.
- Get a full explanation, including comprehensive text and examples, of all known GoF design patterns in Go.
Who This Book Is For
The target audience is both beginner- and advanced-level developers in the Go programming language. No knowledge of design patterns is expected.
What You Will Learn
- All basic syntax and tools needed to start coding in Go
- Encapsulate the creation of complex objects in an idiomatic way in Go
- Create unique instances that cannot be duplicated within a program
- Understand the importance of object encapsulation to provide clarity and maintainability
- Prepare cost-effective actions so that different parts of the program aren't affected by expensive tasks
- Deal with channels and GoRoutines within the Go context to build concurrent application in Go in an idiomatic way
In Detail
Go is a multi-paradigm programming language that has built-in facilities to create concurrent applications. Design patterns allow developers to efficiently address common problems faced during developing applications.
Go Design Patterns will provide readers with a reference point to software design patterns and CSP concurrency design patterns to help them build applications in a more idiomatic, robust, and convenient way in Go.
The book starts with a brief introduction to Go programming essentials and quickly moves on to explain the idea behind the creation of design patterns and how they appeared in the 90's as a common "language" between developers to solve common tasks in object-oriented programming languages. You will then learn how to apply the 23 Gang of Four (GoF) design patterns in Go and also learn about CSP concurrency patterns, the "killer feature" in Go that has helped Google develop software to maintain thousands of servers.
With all of this the book will enable you to understand and apply design patterns in an idiomatic way that will produce concise, readable, and maintainable software.
Style and approach
This book will teach widely used design patterns and best practices with Go in a step-by-step manner. The code will have detailed examples, to allow programmers to apply design patterns in their day-to-day coding.
Table of contents
-
Go Design Patterns
- Go Design Patterns
- Credits
- About the Author
- About the Reviewer
- www.PacktPub.com
- Customer Feedback
- Preface
-
1. Ready... Steady... Go!
- A little bit of history
- Installing Go
- Starting with Hello World
- Integrated Development Environment - IDE
- Types
- Variables and constants
- Operators
- Flow control
- Functions
- Arrays, slices, and maps
- Visibility
- Zero-initialization
- Pointers and structures
- Interfaces
- Testing and TDD
- Libraries
- The Go get tool
- Managing JSON data
- Go tools
- Contributing to Go open source projects in GitHub
- Summary
-
2. Creational Patterns - Singleton, Builder, Factory, Prototype, and Abstract Factory Design Patterns
- Singleton design pattern - having a unique instance of a type in the entire program
- Builder design pattern - reusing an algorithm to create many implementations of an interface
- Factory method - delegating the creation of different types of payments
- Abstract Factory - a factory of factories
- Prototype design pattern
- Summary
- 3. Structural Patterns - Composite, Adapter, and Bridge Design Patterns
- 4. Structural Patterns - Proxy, Facade, Decorator, and Flyweight Design Patterns
- 5. Behavioral Patterns - Strategy, Chain of Responsibility, and Command Design Patterns
-
6. Behavioral Patterns - Template, Memento, and Interpreter Design Patterns
-
Template design pattern
- Description
- Objectives
- Example - a simple algorithm with a deferred step
- Requirements and acceptance criteria
- Unit tests for the simple algorithm
- Implementing the Template pattern
- Anonymous functions
- How to avoid modifications on the interface
- Looking for the Template pattern in Go's source code
- Summarizing the Template design pattern
- Memento design pattern
- Interpreter design pattern
- Summary
-
Template design pattern
- 7. Behavioral Patterns - Visitor, State, Mediator, and Observer Design Patterns
- 8. Introduction to Gos Concurrency
- 9. Concurrency Patterns - Barrier, Future, and Pipeline Design Patterns
- 10. Concurrency Patterns - Workers Pool and Publish/Subscriber Design Patterns
Product information
- Title: Go Design Patterns
- Author(s):
- Release date: February 2017
- Publisher(s): Packt Publishing
- ISBN: 9781786466204
You might also like
book
Go: Design Patterns for Real-World Projects
An insightful guide to learning the Go programming language About This Book Get insightful coverage of …
video
Design Patterns in Go
Design patterns are commonly-used and accepted ways to do common tasks like organizing code, building reusable …
book
API Design Patterns
A collection of best practices and design standards for web and internal APIs. In API Design …
book
Get Programming with Go
Get Programming with Go introduces you to the powerful Go language without confusing jargon or high-level …