Don't Make this Golang Beginner Mistake!

preview_player
Показать описание
In this video, we'll talk about a common mistake that beginners make in Golang when dealing with interfaces. Learn how to avoid this error and improve your Golang coding skills!

Рекомендации по теме
Комментарии
Автор

The same group of people that criticize design patterns are teaching people how to use design patterns.

moneymaker
Автор

I agree on dependency injection, but I disagree on using interfaces right away. I think abstractions are "needed when they are needed" and not when thinking about future possibilities that may or may not occur.
Nonetheless I understand the general point you wanted to convey, thank you for the video!

alessandrodestefano
Автор

Basically dependency injection + strategy pattern. This is a beginner mistake language agnostic

beneditomauroo
Автор

One of the things I love about DI is that it really forces you to think and reason about your dependencies and the number of dependencies that you have. These implicit dependencies can be hiding in your code and until you make them explicit by requiring them to be passed in, sometimes you don't realize just how many you have. Or you may find that some of them are better if they were grouped together which can lead you to better abstractions. Of course, it's a balance, you could take it to far and push everything to the edges, even standard library functions, but I think that's also a part of DI, wrestling with those decisions about what needs to be an explicit dependency and what's okay to just use.

tmanley
Автор

Something I'd also add is DLT. It's always nice to have separate topic where you have all rejected events with header containing reason why event was rejected.

karix
Автор

Just wanted to share that I love how you talked about your community member here and didn’t assume the mistake was a skill issue. Hard-coded dependencies, especially instantiated again and again in a loop, would probably be best to avoid in any language, as others have said. Great video to put out there that helps demonstrate one way to avoid the issue while keeping things positive.

RockyNeurock
Автор

I dont typically code in terms of "what if" scenarios. Doing so will make your code more abstract and complex. Also abstracting across your database is always a headache. Many databases do things fundamentally different and you will find problems attempting to make a suitable interface(s).

dandogamer
Автор

A very nice video that helps newbies understand the use cases of interfaces in Go.

temperkan
Автор

This isn't really a golang mistake. This has more to do with how apis or even codebases are structured. This concept of an interface that encapsulates a service is used everywhere outside of web apis too, heck even outside of the world of programming.
Great video though! Creating abstractions to enable compatibility is certainly valuable knowledge that will help many developers.

Lorofol
Автор

I’m a addicted to Java way of thinking with Service locator. OF COURSE I Don’t have a service locator in golang but I’m embrace to 100% the strategy patterns.
Maybe I will never need to add a second implementation of my service BUT my code is much cleaner since it’s make me create code that don’t depend directly on implémentation details and make my project structure simpler ^^

gungun
Автор

Thanks, as allways perfectly clever explanation. I have question about DI, like here - where and how should be resolved this abstraction? What the most rigth place in project and what style should we use to get balance on clean code, short code, testability etc. ?

ДмитрийКарпич
Автор

From when the 60% discount available for fulltimegodev?

Load_Overlord
Автор

is the D of the SOLID principles, good job btw

miklonDev
Автор

I disagree. You should build that only when there's need for it. Otherwise you're choosing what to spend time on based in your intuition about the future.

thales-maciel
Автор

Hi anthony, great video but i have a question. Can we say that we implemented interface seggregation principle here when creating interface and bind it with your struct in this specific example?

mquanit
Автор

That's a good advice regardless the language you're using.

chepossofare
Автор

Really glad I saw this video. I will never make this mistake since I only write rust. Phew!

prerit
Автор

use this only if you actually need to use different types of persistors, don't think "what if" - that's a rabbit hole

dmitrynizhnikov
Автор

Everyone yelling dependency injection.. this is the dependency inversion principle from SOLID principles.

Rcls
Автор

It seems like you should make some sleep in the end of for loop, for make free proccessor ? cause it could be a leak

maxbro