Introduction

In episode 6, Miki built a logger package with the aim of making it as versatile as possible. To achieve this, he constructed his logger object with a function that would: accept the io.Writer interface as a parameter and perform type assertions to retrieve other interface types as needed. By building this, Miki demonstrated how polymorphism is achieved with Go by changing the type of a variable with type assertions.

In this video, Miki will shift his attention towards the theory side of programming and give a lecture on interface design. The first idea he’ll introduce is that interfaces state what need, not what we provide. To build on this idea, Miki will give a detailed overview of Go’s io.Copy function, its intended use and how the function states that it needs to have a variable to read from and another to write to. The next idea he’ll propose is if an interface has more than five functions, something may be wrong, which can be strongly correlated to the Go proverb the bigger the interface, the weaker the abstraction. Watch and learn more about Go interfaces and the design considerations to keep in mind when writing one.

Things you will learn in this video

  • Criteria to determine the effectiveness of an interface.
  • Quick overview of Go’s io.Reader and io.Writer interfaces.

Video

Trusted by Top Technology Companies

We've built our reputation as educators and bring that mentality to every project. When you partner with us, your team will learn best practices and grow along the way.

30,000+

Engineers Trained

1,000+

Companies Worldwide

14+

Years in Business