Talk given at BostonGolang (bostongolang.org) to an audience of programmers looking to transition to Go from other OO languages. This gives a good overview of how Go does OO differently and how to do it idiomatically.
About this talk Beginner to Intermediate level Basic understanding of OOP from another language for context Some familiarity with Go syntax expected but not mandatory
OOP OOP tends to model concepts as “objects” that interact with other objects within the world of your program Most are familiar with class-based OOP Java, C++, Objective-C, Ruby, Python and others, all embrace class-based OO
OOP “Objects” have both data (state) and behavior (code, often called “methods”) Behaviors access and often modify object state Objects tend to have the notion of “self” or “this”
OOP “Objects” represent “instances” of “classes” in common OO languages Class-based orientation commonly includes Inheritance and Polymorphism OO programmers have come to favor composition over inheritance
In a Nutshell Go has types and values rather than classes and objects Go provides many of the same features we're used to in classical- orientated languages: methods on any type automatic message delegation through embedding polymorphism through interfaces Go does not have inheritance, no "is-a" relationships between objects Go relies on composition for OO