课程: Treating Go as an Object-Oriented Language
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Structs as classes
- [Instructor] Go is not an object-oriented language as I just stated. But the first similarity that we can leverage while treating Go as a pseudo object-oriented language is through the use of structs as classes. Now, let's first talk about a class in OOP. My assumption here is that you have familiarity with the paradigm, so I will keep this very high level. At its core, a class is a template for an object. A class has attributes or variables that are part of the object when it is created. A class also has methods or functions, and these procedures can act on the data within the class within that object or can act external to that. And while many languages provide classes, they all ultimately are user defined even if that user was one of the core library developers. So classes other than the base class are always user defined. So let's talk about Go structs and how they're similar to classes. Go structs, like classes are…
内容
-
-
-
-
(已锁定)
Structs as classes2 分钟 21 秒
-
(已锁定)
Creating a struct5 分钟 16 秒
-
(已锁定)
Encapsulation2 分钟 43 秒
-
(已锁定)
Leveraging encapsulation5 分钟 35 秒
-
(已锁定)
Solution: Struct as class2 分钟 2 秒
-
(已锁定)
Composition1 分钟 36 秒
-
(已锁定)
Leveraging composition4 分钟 11 秒
-
(已锁定)
Polymorphism2 分钟 59 秒
-
(已锁定)
Leveraging polymorphism4 分钟 49 秒
-
(已锁定)
Solution: OOP4 分钟 56 秒
-
(已锁定)
-