Labs / Python OOP

The Most Beginner-Friendly Object Oriented Programming Tutorial on the Whole Network: 01 Basic Concepts of Object Oriented Programming

Author: Li Zisheng · Source: FreakStudio open documentation · License: CC BY 4.0

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:

51

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.

The Most Beginner-Friendly Object Oriented Programming Tutorial on the Whole Network: 01 Basic Concepts of Object Oriented Programming
0

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:

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

The Most Beginner-Friendly Object Oriented Programming Tutorial on the Whole Network: 01 Basic Concepts of Object Oriented Programming

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.

https://github.com/leezisheng/Python-OOP-Demo

Python Object Oriented Sample Program

The Most Beginner-Friendly Object Oriented Programming Tutorial on the Whole Network: 01 Basic Concepts of Object Oriented Programming
The Most Beginner-Friendly Object Oriented Programming Tutorial on the Whole Network: 01 Basic Concepts of Object Oriented Programming

Previous Recommendations:

For more information about the document, please refer to:

You who are learning embedded systems still don't know Object Oriented? ?!

The Most Beginner-Friendly Object Oriented Programming Tutorial on the Whole Network: 00 Introduction to Object Oriented Design Methodology

Speed Up Your Python: A Quick Guide to Python Parallel Computing

Understand the Debugging Principle of CM3 Microcontroller in One Article

After half a month of dedicated grinding, the ultimate summary of embedded technology stack is now released

The "Secret Martial Arts Manual" for Computer Science Competitions