O'Reilly logo

Get Programming with Go by Nathan Youngman and Roger Peppé

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unit 5. State and behavior

In Go, values represent state, such as whether a door is opened or closed. Functions and methods define behavior—actions on state, such as opening a door.

As programs grow larger, they become more difficult to manage and maintain, unless you have the right tools.

If there are several doors that can independently be opened or closed, it’s helpful to bundle the state and behavior together. Programming languages also allow you to express abstract ideas, such as things that can be opened. Then on a hot summer day, you can open everything that can be opened, whether door or window.

There are a lot of big words to describe these ideas: object-orientation, encapsulation, polymorphism, and composition. The lessons in this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required