How to design base class and derived class?

UE5 Plugin Development Guide

foreword

The focus of this article is to sort out the ideas of writing code. When we come into contact with a project, we will see many functions described in the requirements document. Expansion, player shortcut bar expansion, at this time we actually need to think about how to implement these functions, which of them can be reused, so as to improve development efficiency.
different items
As shown in the figure, just like extracting common factors in algebra, we can extract the common points in these functions and turn them into base classes, and implement these public properties and methods in the base class. We can draw a The mind map is as follows:
Item unit mind map
no matter what the items are, these items have the same characteristics, so that they can have a common base class, and then we will analyze what attributes and methods this base class needs to have. The mind guide The figure is as follows:
Item base class mind map
the base class of the item unit is to extract all the common features of the item, and leave the different places for subclasses to expand. This is an object-oriented feature: inheritance, encapsulation, and polymorphism.
Here we need to explain why the item unit has two numbersÿ

Guess you like

Origin blog.csdn.net/qq_30137245/article/details/130888310