[Go] Object-oriented (1): Overview

Package

  • Encapsulate variables and functions that are similar in business into structures (classes)
  • Reduce the number of directly managed members, facilitating large-scale development

inherit

  • Extract the common part to the parent class to reduce duplication of code

Polymorphism

  • A parent category has many different specific sub-category forms

  • Commonality: dispatch subclass instances by calling the parent class method

  • Personality: different subclasses have different abstractions for the concrete realization of the parent class method

  • The parent interface only defines methods, not specific implementations

Guess you like

Origin blog.csdn.net/qq_36045898/article/details/113983013