We may earn an affiliate commission when you visit our partners.
Course image
Udemy logo

Working with Design Patterns in Go (Golang)

Trevor Sawler

Go is a powerful language for building efficient and scalable applications. But as your projects grow, you'll encounter common problems that can be elegantly solved with design patterns.

Read more

Go is a powerful language for building efficient and scalable applications. But as your projects grow, you'll encounter common problems that can be elegantly solved with design patterns.

This course will equip you with the knowledge and skills to leverage these design patterns effectively in your Go code. We'll explore various categories of patterns, including:

  • Creational Patterns: Learn techniques for object creation that promote flexibility and decoupling.

  • Structural Patterns: Discover ways to compose classes and objects to achieve desired functionality.

  • Behavioral Patterns: Explore patterns that define communication and interaction between objects.

By understanding these patterns, you'll gain the ability to:

  • Write cleaner, more maintainable, and reusable code.

  • Improve the design and architecture of your Go applications.

  • Solve common programming challenges with proven solutions.

  • Communicate design concepts more effectively with other developers.

We'll approach design patterns with a practical lens, focusing on real-world Go scenarios. In fact, we'll build a simple web application that allows us to see how, why, and when you can use a particular design pattern to make your code more efficient, maintainable, and easy to understand. My goal is ensure that you'll gain hands-on experience implementing these patterns so that you can use them in your own projects.

So, whether you're a seasoned Go developer or just getting started with the language, this course will provide you with valuable tools to take your Go development skills to the next level.

Enroll now

What's inside

Learning objectives

  • How to use common design patterns in go
  • Streamline the software development process by using well known patterns
  • Learn how to create loosely coupled software components
  • Build a real-world application using design patterns

Syllabus

What are design patterns and how do we use them; setting up our development environment.
Introduction
A bit about me
Installing Go
Read more
Installing an Integrated Development Environment
Installing Docker
Asking for Help
Mistakes. We all make them.
Let's build a simple web application, which we'll expand upon as the course goes on.
What we'll build in this section
How web applications work
Setting up our main application
Installing a routing package
Setting up routes
Setting up a simple HTML template
Creating a render function
Rendering our first page
Adding navigation
Creating templates for all site pages
Setting up a route & handler for site pages
Trying out our template cache
Adding WebP and jpeg images to the home page
Let's look at a couple of commonly used creational patterns: the Factory Pattern, and the Abstract Factory Pattern.
The Factory Pattern
Setting up some types
Creating a simple Factory
Creating handlers for the simple Factory
Setting up the front end
Adding routes for our Factory handlers
Trying our Factory pattern out
The Abstract Factory pattern
Creating an Abstract Factory
Creating a route and handler for the Abstract Factory
Updating the front end
Trying out our Abstract Factory
We want our application to have a database, so let's set one up and connect to it.
Getting started with the Builder pattern in our project
Adding a module to support MySQL/MariaDB
Setting up a local MariaDB instance with Docker
Connecting our application to MariaDB
Let's implement database functionality, and then improve it using the Repository Pattern.
Writing our first database function
Creating a handler to list dog breeds
Updating the front end to fetch the list of dog breeds
Updating the front end to display the list of dog breeds
Writing a test for our handler
Implementing the Repository pattern I
Implementing the Repository pattern II
Implementing the Repository pattern III
Trying things out
Implementing a test database repository
Updating our handler test
Let's write our first singleton -- a pattern that allows to create one, and only one, instance of an object.
Setting up our Builder code
Creating a simple Singleton
Updating our project to use our configuration package (singleton)
The builder pattern is another creational pattern that allows us to chain methods, and the fluent interface is closely related. Let's look at them.
The Builder Pattern (& Fluent Interface)
Fixing three problems with our Builder code
Setting up a handler to use our Builder pattern
Setting up a route to our handler
Modifying the front end to call our Builder route
Challenge
Solution to challenge
The adapter pattern is arguably one of the most useful patterns to creating easy to maintain code. Let's implement it.
What we'll cover in this section
The Adapter Pattern - Overview
Installing an application to serve JSON and XML
Setting up the Adapter type & the Adaptee
Adding the Adapter to our application config
Setting up a handler
Adding a route
Updating the Cat Breeds template
Switching adapters from JSON to XML
Adding a test for the Cat Breeds handler, using our adapter pattern
Let's use the repository, adapter, singleton, and abstract factory patterns all at once.
Creating a stub AnimalFromAbstractFactory handler
Creating a New factory function for pet with embedded breed
Creating stub newPetWithBreed method for Cats and Dogs
Adding a GetDogBreedByName method in the database Repository
Refactoring adapters.go to new package
Adding a GetCatBreedByName method on our JSON adapter
Adding a GetCatBreedByName method on our XML adapter
Finishing up the new Adapter and Abstract Factory code
Finishing up the changes in our Abstract Factory to use the new adapters
Setting up a route to our stub handler
Finishing off the handler code
Updating the front end to try things out
Writing the necessary javascript to call our back end
Let's explore how we can add information and functionality to an object by using the Decorator Pattern.
Setting up a route and a stub handler
Setting up the database table
Adding database methods for Dog of Month

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Explores design patterns, which are industry standard across many languages
Taught by Trevor Sawler, who is well recognized for their work in developing design patterns
Develops foundational and advanced programming skills using design patterns, which are essential qualities for professional software development
Builds up to a useful and practical final project, allowing for an edge in understanding how these patterns can be applied in real world scenarios
Covers a comprehensive range of design patterns, reinforcing deep expertise in programming
Requires prior experience with programming, however the prerequisite knowledge should be accessible to most learners

Save this course

Save Working with Design Patterns in Go (Golang) to your list so you can find it easily later:
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Working with Design Patterns in Go (Golang) with these activities:
Refresher: Design Patterns
Review design patterns to strengthen your grasp of the concepts that will be covered in this course.
Browse courses on Creational Patterns
Show steps
  • Review the definitions of creational, behavioral, and structural patterns.
  • Go over some common examples of each type of pattern.
  • Think about how you might apply these patterns to your own coding projects.
Study Group for Go Design Patterns
Join a study group or create one of your own to discuss design patterns with other students and reinforce your understanding.
Show steps
  • Find or create a study group with other students in your course or online.
  • Set regular meeting times to discuss the course material and design patterns.
  • Work together to solve problems, complete assignments, and prepare for exams.
Hands-on Design Pattern Practice
Practice implementing design patterns in Go to solidify your understanding and gain practical experience.
Show steps
  • Set up a development environment with Go and an IDE.
  • Follow along with the course examples and implement the design patterns in your own code.
  • Create your own small Go project and apply the design patterns you've learned.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Explore Design Patterns in Go
Seek out tutorials and resources to expand your knowledge and understanding of design patterns in Go.
Show steps
  • Search for tutorials on design patterns in Go.
  • Follow along with the tutorials and implement the design patterns in your own code.
  • Join online forums or communities where you can ask questions and discuss design patterns with other developers.
Design Patterns Challenge
Participate in a coding challenge or competition that focuses on design patterns in Go. This will test your skills and provide motivation to learn and improve.
Show steps
  • Find a coding challenge or competition that aligns with your interests.
  • Study the rules and requirements of the challenge.
  • Develop a solution that demonstrates your understanding of design patterns.
  • Submit your solution and compete against other participants.
Design Patterns in Go: A Guide
Create a blog post, article, or presentation to reinforce your understanding of design patterns in Go and share your knowledge with others.
Show steps
  • Choose a specific design pattern or set of patterns to focus on.
  • Write about the purpose, benefits, and implementation of the design patterns.
  • Include examples and code snippets to illustrate your points.
  • Publish your content online and share it with the community.
Design Patterns in Go Application
Develop a small-scale Go application that demonstrates the use of design patterns. This will provide hands-on experience and strengthen your understanding of how to apply design patterns in real-world scenarios.
Show steps
  • Identify a problem or use case that can be solved using design patterns.
  • Design the architecture of your application, including the classes, objects, and relationships between them.
  • Implement the design patterns in your code.
  • Test and debug your application to ensure it works correctly.

Career center

Learners who complete Working with Design Patterns in Go (Golang) will develop knowledge and skills that may be useful to these careers:

Reading list

We haven't picked any books for this reading list yet.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Here are nine courses similar to Working with Design Patterns in Go (Golang).
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser