* Allow for easy testing and mocking, especially to external services
* Allow for easy swap out of functionality
* Allow for useful tactics like type switching, etc.
And a note on YAGNI:
> software rarely undergoes radical changes once in production
Depends on your definition of radical. But it's not uncommon to switch underlying databases, APIs, cloud providers (if using cloud native components), etc. "Yagni requires (and enables) malleable code." - Martin Fowler. According the Fowler interfaces ARE the definition of YAGNI.
People think Go is just like another language. I did when starting Go. And wanted to change many things in Go. After some months I do think Go is fine.
One thing I didn't use was embedded structs, I've used Interface more like in Java and Typescript. Now I use more embedded structs for what I would have used interfaces for and use interfaces more for embedding behaviour inside structs.
2 comments
[ 3.6 ms ] story [ 17.7 ms ] thread* Allow for easy testing and mocking, especially to external services
* Allow for easy swap out of functionality
* Allow for useful tactics like type switching, etc.
And a note on YAGNI:
> software rarely undergoes radical changes once in production
Depends on your definition of radical. But it's not uncommon to switch underlying databases, APIs, cloud providers (if using cloud native components), etc. "Yagni requires (and enables) malleable code." - Martin Fowler. According the Fowler interfaces ARE the definition of YAGNI.
YAGNI: Ya ain't gonna need it...until you do.
One thing I didn't use was embedded structs, I've used Interface more like in Java and Typescript. Now I use more embedded structs for what I would have used interfaces for and use interfaces more for embedding behaviour inside structs.