课程: Treating Go as an Object-Oriented Language
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Encapsulation
- [Instructor] Encapsulation is a primary pillar of object-oriented programming, and something that we get in Go as well. Encapsulation is a very important concept, especially when writing libraries. It allows you to provide protection to your internal data and logic. Think about our dog example, everything was exposed as we saw from the main method itself. We could get access to all of the data and all of the methods. Encapsulation is a way to protect that. Data contained in structs can be protected from access outside the package itself in the same way methods on a struct can be protected. It's important to note that interfaces which we will talk about later, can have protected, or hidden methods, which is different than you see in interfaces in some other languages, specifically Java. Another benefit and one that goes along with protection is that encapsulation allows you to control the flow of data, both the setting…
内容
-
-
-
-
(已锁定)
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 秒
-
(已锁定)
-