► 33% OFF on my Go + HTMX + Templ Course PRESALE 👉bit.ly/3UFruxO ► Join my Discord community for free education 👉 discord.com/invite/Ac7CWREe58 ► Exclusive Lessons, Mentorship, And Videos 👉 www.patreon.com/anthonygg_ ► 60% OFF on my Golang course 👉 fulltimegodev.com Thanks for watching
Like those OOP tutorials we all read when we first started learning programming. Create a Car class. Give it model and color properties. Add drive and honk methods. MyCar.honk(). "Beep, beep!" Ok, now what? How about a practical example? Fuck that, now you surely understand OOP, onto the next half-assed subject.
@@ada0015 anywhere where you need a bunch of configs. moreover what anthony has shown here is an open ended design. meaning you wont have breaking api changes
The video demonstrates how to refactor a simple Go application to use interfaces, highlighting the benefits of dynamic behavior and testability. Key moments: 00:01 Interfaces can be confusing for people, but using them in applications can clarify their purpose and benefits, especially for those aspiring to be Go engineers. -Creating a simple application to demonstrate interface usage can help developers understand when and how to utilize interfaces effectively. -Implementing a notification system with different methods like email, SMS, or Slack can showcase the versatility of interfaces in handling various functionalities. 03:41 The video discusses refactoring code to use interfaces, emphasizing the importance of error handling and context in Go programming. It also touches on dependency injection and state management in code design. -Importance of error handling and context in Go programming for interfaces. It highlights the significance of returning errors and using context to manage timeouts and cancellations. -Discussion on dependency injection in code design, focusing on the need for a mechanism to attach state to handlers. It explains the concept in the context of creating a struct for account handling. 07:24 The video discusses implementing an account Notifier interface in Go programming language, creating a simple account Notifier structure, and utilizing the context package for handling notifications efficiently. -Creating an instance of the account Handler and implementing the account Notifier interface for handling account notifications efficiently. -Utilizing the context package for handling notifications and demonstrating a simple implementation of account notifications in Go programming. 11:31 Using interfaces in Go can allow for dynamic and flexible code changes, as demonstrated by swapping account notifier implementations easily. It showcases the power and versatility of interfaces in Go programming. -Demonstrating how to swap account notifier implementations by passing a new implementation, showcasing the flexibility of interfaces in Go programming. -Discussing the appropriate use of interfaces in Go, highlighting the importance of interfaces for attaching state in certain implementations like API Keys or caching systems.
Great exemplification of a good practice by using simple yet powerful patterns. I think a video showing "the over-engineering" use of interfaces would also be nice :D
or you can attach preference property on Account and create NotificationFactory which creates proper implemntation then you don't have to change anything just create new impl. Awesome video!
Hey Anthony, thanks for the great video. For a next video, would it be possible to see how you would implement storage interfaces in an API? You started something like in a previous video "how to structure a go project".
The worst thing about interface tutorials, and the “polymorphism” examples in C++ classes in school, are the usual shape example. While it gets you going, it’s not practical at all. This tutorial made the whole paradigm so much easier to understand.
I'm thinking about how to build htmx+templ forms using interfaces for different form input types. We always have value+error strings for form params--we can make an interface to fill them in programmatically. So we can define a form as a slice of FormInputType enums and have the interface implementation fill out the template with those form inputs from the slice. For example, FormInputType{UsernameInput,PasswordInput} can be passed to some form builder with the value/error params
🎯 Key Takeaways for quick navigation: 00:00 *🛠️ Interfaces in Go can be confusing for some, especially regarding when and how to use them effectively.* 01:36 *📡 Implementing a notification system after specific actions in your application is a common practice, such as notifying users or admins via various channels.* 03:42 *🔄 Refactoring code to use interfaces is beneficial for scenarios where implementations may vary, such as different notification methods.* 06:14 *⏳ When designing systems with potential IO operations, using contexts is crucial for managing timeouts and ensuring application determinism.* 08:32 *📜 Dependency injection through interfaces allows for flexible and dynamic behavior without modifying core logic repeatedly.* 11:44 *🔄 Utilizing interfaces enables easy swapping of implementations, improving code flexibility and maintainability.* 13:54 *🔥 Proper understanding and usage of interfaces in Go can lead to more idiomatic, composable, and maintainable code.*
One question, in this video you changed the behaviour by swapping the implementation, but what if I have a few structs that carry configurations and each implementation has a different configuration. Is there a way to address that?
Hi Anthony, really great video as always, it's much appreciated by many. I was wondering if you've got anything in the pipeline, or considered, putting out some "go gym" type videos. And by that I mean smaller exercises that people can do in order to get better. TLDR: Are you considering project suggestions as part of your content?
► 33% OFF on my Go + HTMX + Templ Course PRESALE 👉bit.ly/3UFruxO
► Join my Discord community for free education 👉 discord.com/invite/Ac7CWREe58
► Exclusive Lessons, Mentorship, And Videos 👉 www.patreon.com/anthonygg_
► 60% OFF on my Golang course 👉 fulltimegodev.com
Thanks for watching
So much better than the overused geometry/shapes interface example. Well done.
exactly, especially if you come from a Java or C# background, it looks really silly when people talk about all that
Like those OOP tutorials we all read when we first started learning programming. Create a Car class. Give it model and color properties. Add drive and honk methods. MyCar.honk(). "Beep, beep!" Ok, now what? How about a practical example? Fuck that, now you surely understand OOP, onto the next half-assed subject.
You dropped this video just as I am building my own notifications engine in golang with support for various connectors🤣
I'm new to Golang (
@@ada0015 anywhere where you need a bunch of configs. moreover what anthony has shown here is an open ended design. meaning you wont have breaking api changes
i love these high level golang videos that focus on patterns
Fantastic video Anthony, thanks a lot!
The video demonstrates how to refactor a simple Go application to use interfaces, highlighting the benefits of dynamic behavior and testability.
Key moments:
00:01 Interfaces can be confusing for people, but using them in applications can clarify their purpose and benefits, especially for those aspiring to be Go engineers.
-Creating a simple application to demonstrate interface usage can help developers understand when and how to utilize interfaces effectively.
-Implementing a notification system with different methods like email, SMS, or Slack can showcase the versatility of interfaces in handling various functionalities.
03:41 The video discusses refactoring code to use interfaces, emphasizing the importance of error handling and context in Go programming. It also touches on dependency injection and state management in code design.
-Importance of error handling and context in Go programming for interfaces. It highlights the significance of returning errors and using context to manage timeouts and cancellations.
-Discussion on dependency injection in code design, focusing on the need for a mechanism to attach state to handlers. It explains the concept in the context of creating a struct for account handling.
07:24 The video discusses implementing an account Notifier interface in Go programming language, creating a simple account Notifier structure, and utilizing the context package for handling notifications efficiently.
-Creating an instance of the account Handler and implementing the account Notifier interface for handling account notifications efficiently.
-Utilizing the context package for handling notifications and demonstrating a simple implementation of account notifications in Go programming.
11:31 Using interfaces in Go can allow for dynamic and flexible code changes, as demonstrated by swapping account notifier implementations easily. It showcases the power and versatility of interfaces in Go programming.
-Demonstrating how to swap account notifier implementations by passing a new implementation, showcasing the flexibility of interfaces in Go programming.
-Discussing the appropriate use of interfaces in Go, highlighting the importance of interfaces for attaching state in certain implementations like API Keys or caching systems.
Great exemplification of a good practice by using simple yet powerful patterns. I think a video showing "the over-engineering" use of interfaces would also be nice :D
Which Rest API VS Code extension do you use? Great video. Thanks.
I think it is Thunder Client
@@LourensRolograaf Correct!
Spent time wonderfully.
Great Explanation with a useful example, I would love to see in this particular example a way to chain multiple Notifiers in a slice!
Brilliant yet concise video.
That was beautiful. Instantly subscribed!
Yeah this is great stuff. As always 🔥
Anyone know what color theme Anthony is using?
Gruvbox
or you can attach preference property on Account and create NotificationFactory which creates proper implemntation then you don't have to change anything just create new impl. Awesome video!
Hey Anthony, thanks for the great video. For a next video, would it be possible to see how you would implement storage interfaces in an API? You started something like in a previous video "how to structure a go project".
Thanks for the video. What is the extension you use in vscode for creating http requests in a new tab to test the code?
Thunder client
The worst thing about interface tutorials, and the “polymorphism” examples in C++ classes in school, are the usual shape example.
While it gets you going, it’s not practical at all.
This tutorial made the whole paradigm so much easier to understand.
very easy to understand explanation
I'm thinking about how to build htmx+templ forms using interfaces for different form input types. We always have value+error strings for form params--we can make an interface to fill them in programmatically. So we can define a form as a slice of FormInputType enums and have the interface implementation fill out the template with those form inputs from the slice. For example, FormInputType{UsernameInput,PasswordInput} can be passed to some form builder with the value/error params
🎯 Key Takeaways for quick navigation:
00:00 *🛠️ Interfaces in Go can be confusing for some, especially regarding when and how to use them effectively.*
01:36 *📡 Implementing a notification system after specific actions in your application is a common practice, such as notifying users or admins via various channels.*
03:42 *🔄 Refactoring code to use interfaces is beneficial for scenarios where implementations may vary, such as different notification methods.*
06:14 *⏳ When designing systems with potential IO operations, using contexts is crucial for managing timeouts and ensuring application determinism.*
08:32 *📜 Dependency injection through interfaces allows for flexible and dynamic behavior without modifying core logic repeatedly.*
11:44 *🔄 Utilizing interfaces enables easy swapping of implementations, improving code flexibility and maintainability.*
13:54 *🔥 Proper understanding and usage of interfaces in Go can lead to more idiomatic, composable, and maintainable code.*
One question, in this video you changed the behaviour by swapping the implementation, but what if I have a few structs that carry configurations and each implementation has a different configuration. Is there a way to address that?
U can pass the config when initialize your implementation
Why is changing or creating a new notifier strictly better than modifying the handler?
Thanks so much!
Great!!❤
Anthony Can you show builtin golang Interface and examples for brain ruins 😄
why make a state for an API key as the context value is made for that ?
Hi Anthony, really great video as always, it's much appreciated by many.
I was wondering if you've got anything in the pipeline, or considered, putting out some "go gym" type videos. And by that I mean smaller exercises that people can do in order to get better.
TLDR: Are you considering project suggestions as part of your content?
Go daddy
a bit like strategy pattern
The most confusing video on interface i've seen so far!