November 2017
Intermediate to advanced
670 pages
17h 35m
English
Object-oriented programs (OOP) consists of stateful objects that support object-related operations, called methods, whose implementation and internal structure is hidden. This means you can evolve or replace the internals of an object without the clients of that object also having to change. It also means that changes can occur to the hidden data without your knowledge, which, as we've seen, can be a bad thing. OOP also includes the idea of inheritance, where a new object could base its state and implementation on another object higher up in its hierarchy, which can cause your program to become rigid and more difficult to change. Here is a Car object and its Add method:
type Car struct { Model string}func (cars *Cars) Add(car ...