Contents
Abstract
This article mainly introduces the basic concepts of Object Oriented programming: classes and objects, the three major features - inheritance, encapsulation and polymorphism, the basic concepts of UML class diagrams and object diagrams, as well as the required Development Environment for the tutorial.
Below, we will briefly introduce the basic concepts of Object Oriented programming and graphical description methods, and we will provide detailed explanations with specific programming examples in the subsequent chapters.
Class and Object (Category 1)
An object is a collection of data and its behaviors, while a class is often used to describe a collection of objects that share the same attributes and methods. It defines the attributes and methods common to every object in that collection. For example, apples and oranges belong to two different classes: apples fall into the apple class, and oranges fall into the orange class.
So what is the difference between an object and a class? A class is used to describe objects, and they are like a blueprint for creating objects. For example, there are 3 oranges on the table in front of you, each of which is a distinct object, yet all 3 oranges share the same attributes and behaviors stemming from the same class, the general category of oranges.
An object (an orange) is an instance of a class (the orange class).
Here, we can eat apples, peel apples, and wash apples — this is the method in an object. Meanwhile, different oranges vary in weight, sweetness and price, which are the properties of an orange object that typically represent the individual characteristics of a specific object.
2 The Three Core Characteristics of Object Oriented: Inheritance, Polymorphism and Encapsulation
Here I'd like to borrow an answer from a top contributor on Zhihu for a vivid explanation:

3 Unified Modeling Language (UML)
UML stands for Unified Modeling Language, which is a standardized modeling language consisting of a complete set of diagrams. UML is used to help system developers specify, visualize, construct and document the artifacts of software systems. UML represents a series of practices that have proven successful in modeling large and complex systems, and it is a very important part of developing Object Oriented software and the software development process.
For beginners, mastering UML class diagrams and object diagrams is sufficient, and you can use tools such as Boardmix to draw UML class diagrams during your own project development.


4. Programming Environment
The sample code is available in the following repository:
Master Python Object Oriented Programming in One Article - Document Sample Program
This folder contains the following files:
- DateProcess.py: A data processing class, which mainly defines the attributes and methods of DateProcessClass, and defines the DateProcessInterface interface;
- FileIO.py: File saving class, which defines the attributes and methods of FileIOClass;
- main.py: The main program, which defines the attributes and methods of the sensor class and the host class, and calls other modules;
- Parallel.py: Sample programs related to Python multithreading and multiprocessing;
- Plot.py: Plotting class, which defines the attributes and methods of PlotClass;
- Serial.py: A serial communication class that defines the attributes and methods of SerialClass;
- environment.yml: Virtual environment configuration file;
- Object.srctrlprj: Can be opened with the Sourcetrail software to better understand the code;
- test.py: can be ignored;
The main dependent libraries and their version numbers for the sample code in this document are as follows:
Dependency Library | Version Number |
matplotlib | 3.8.4 |
matplotlib-base | 3.8.4 |
pyqt | 5.15.9 |
pyqtgraph | 0.13.7 |
python | 3.12.1 |
pandas | 2.2.0 |
pillow | 10.2.0 |
pyserial | 3.5 |
zope-interface | 6.3 |
The relevant environment can be reconstructed by importing the environment.yml file from the sample program using conda.
Starting from the next section, we will officially dive into the main part of the tutorial. Don't forget to hit the follow button, guys!
Document Acquisition
You can access the following link to download the document:
https://github.com/leezisheng/Doc

This document mainly introduces how to use Python for Object Oriented programming, and requires readers to have a basic understanding of Python syntax and microcontroller development. Compared with other blogs or books that explain Python Object Oriented programming, this document is more detailed and focuses on embedded host computer applications. It takes the common serial port data transmission and reception, data processing, dynamic graph drawing and other functions between the host computer and the lower computer as application examples, and uses the Sourcetrail code software to visually read the code to facilitate readers' understanding.
The link to obtain the relevant sample code is as follows:
https://github.com/leezisheng/Python-OOP-Demo
Python Object Oriented Sample Program


Previous Recommendations:
For more information about the document, please refer to:
You who are learning embedded systems still don't know Object Oriented? ?!
Speed Up Your Python: A Quick Guide to Python Parallel Computing
Understand the Debugging Principle of CM3 Microcontroller in One Article
The "Secret Martial Arts Manual" for Computer Science Competitions