Working with Go offers you the freedom to write clean and concise code that isn't cluttered with a lot of boilerplate. This course gives an introduction to object-oriented programming concepts, why they are important, and how to apply them in Go.
The Go language offers a fresh way to look at how a programming language can be constructed. Each language structure is considered in light of how the developer and the compiler need to interact with it. While this has led to a language that is very clear and concise, it can make it difficult to recognize how conventional design approaches, such as object-oriented programming can be applied. In this course, Object-oriented Programming with Go, you'll learn the major concepts of object-oriented programming, and see how they can be implemented in Go applications. First, you'll discover how to hide implementation details of a service with encapsulation. Next, you'll explore the difference between inheritance and composition, and why Go only supports one of them. Finally, you'll cover how to use interfaces to completely decompile code from the objects that it's using. By the end of this course, you'll have a solid understanding of the major principles of object-oriented programming, and how to apply them efficiently in Go.
Michael Van Sickle is an application architect in Akron, Ohio.
He is a mechanical engineer by training and a software engineer by choice.
He is passionate about learning new programming languages and user
Course Overview Hi everyone. My name is Michael Van Sickle, and welcome to my course, Object-oriented Programming with Go. Many engineers that work with Go love the freedom that it offers to write clean, concise code that isn't cluttered with a lot of boilerplate such as getter and setter methods for struct fields. This freedom from the constrictions that many object-oriented languages come with, does have a cost, however. It's easy to write Go code without considering the advantages that object orientation brings. In this course, we're going to learn what object-oriented programming is supposed to be, and how to apply its concepts in Go when it makes makes sense to do so. Some of the major topics that we'll cover include how to hide implementation details of service with encapsulation, what message passing is and how it differs from just calling a method on an object, the difference between inheritance and composition, and why Go only supports one of them, how to use interfaces to completely decouple code from the objects that it's using. By the end of this course, you'll know about the major principles of object-oriented programming, and how to apply them judiciously in Go. Before beginning the course, however, you should be familiar with the basics of programming in Go. I hope you'll join me on this journey to learn about object orientation and when it's a good thing in Go with the Object-oriented Programming with Go course at Pluralsight.
Introduction Hello. My name is Michael Van Sickle. One of the things that I love most about the Go language is its willingness to break the trend that many strongly-typed languages have fallen into, where everything is an object, and writing applications in an object-oriented way is the only way that is discussed. With Go, we don't have classes, abstract methods, or any of the other things typically associated with an object-oriented language. Instead, we have options. Sometimes object orientation makes sense, but sometimes it adds unnecessary complexity to the code. In this course, we're going to talk about what object-oriented programming is, and how to apply it in Go applications. Before we go any farther, however, let's take a look at two different applications that represent part of a payment processing application. One uses an object-oriented style, and the other follows a more typical procedural approach.
Encapsulation The first aspect of object-oriented programming that we're going to tackle is the idea of encapsulation. Now we're going to go through this module with a pretty simple structure. We're going to start by talking about what encapsulation is. So I want to cover the basic concepts of encapsulation so that we're all on the same page as we understand what encapsulation is trying to do for us as we use it in our object-oriented applications. And then I want to move on to talk about the strategies that we can use based on the tools that are available in Go to apply the concept of encapsulation to our Go programs. Okay, so let's dive in and talk about what encapsulation is, and how we can apply it to our applications.
Message Passing In the last module, we learned that encapsulation is about allowing an object to provide a service without giving details of how that service is implemented. Message passing takes that a step forward by abstracting away which service is being provided in the first place. So we're going to cover message passing in a format very similar to the last module. We're going to start by defining what message passing is. So we'll talk about a definition of message passing, and then we'll talk about how to apply that when you're doing object-oriented programming, and the advantages that that's going to bring to your application. And then we'll talk about the strategies that are available in Go to add message passing to your application. Now one of the cool things about Go is that one of the strategies that we're going to be exploring doesn't even involve objects. So here we go again with the quirky nature of Go. We're going to be able to implement object-oriented patterns without even using objects. Okay, but our first step is to learn what message passing is, and what advantages it can bring to our application, so let's take a look at that.
Composition So far, we have talked about techniques that allow us to relieve the consumers of our objects from knowing details about the objects. Encapsulation allows consumers to request services without knowing the implementation details, and the message passing allows the objects to decide how to handle a request for a service. In this module, we're going to talk about another foundational concept in object-oriented programming, how to reuse existing behaviors. Now there are two strategies that are typically used to reuse behaviors in object-oriented systems. The first is inheritance and the second is composition, so I want to talk about both of those concepts to begin this module so that we understand the difference between the two. And then we'll talk about the strategies that Go offers us to reuse behaviors in our systems. Okay, so let's get started by talking about inheritance and composition, and how they're the same, and how they're different.
Polymorphism So far in this course, we've talked about how object-oriented principles allow us to reuse functionality, encapsulate services, and provide a layer of indirection between a request for a service and the actual service that is provided. In this final module, we're going to wrap things up with a discussion of how to go even farther with our abstractions and abstract the type itself that is providing the services. We'll do this using a technique called polymorphism. So we're going to start our discussion by talking about what polymorphism is, and once again, we'll go through a definition of polymorphism and see at a very high level how polymorphism works. And then we'll talk about the strategies that Go makes available to us to add polymorphism into our applications. Okay, so let's go ahead and get started.