Google’s Go programming language, a statically typed compiled language, has been called a modern, better C. It builds on C by adding features such as garbage collection, concurrency constructs, and user-defined class-like types. One missing feature is classical object-oriented inheritance. Instead, Go uses interfaces and structural typing. Structural typing is like compile time duck typing. …
Encapsulation is often called the core of object-oriented programming. Data is bundled with the functions that operate on that data. However, too much behavior can lead to monolithic, incohesive classes. The type class pattern preserves a class’s core behavior but defines orthogonal behaviors externally. Type classes allow you to “extend” both user-defined and native classes …