Abstraction, Encapsulation and Inheritance in Embedded Development

Abstraction, Encapsulation and Inheritance in Embedded Development

## 1 How to achieve it?

OOP is a distinguishing feature of CPP despite being a multi-paradigm language

The first part talks about the implementation of the product rather than the design of the product, because for individual developers, they often know how to implement the product before starting to do the overall design. This isn't to say that implementation trumps design, but rather an acknowledgment that the primary driver of such developers is often not user needs, but a passion to try new things.

insert image description here

Trying something new is based on some principles. From the beginning of learning circuit principles in the first grade, the analysis principle of "pre- and post-level independence" under the guidance of Kirchhoff's laws is engraved in the hearts of every preparatory engineer majoring in electronics/control/instrumentation. Various software engineering implementation principles also remind us of the importance of modular design for system maintainability and scalability. That is to say, the modularization of the product should be carried out as early as possible. It is best to disassemble the product into multiple requirements modules during the requirements analysis stage. In the subsequent design, it is only necessary to define the connection relationship between each requirements module.

insert image description here

Although C++ (C PLUS PLUS) is a language with multiple paradigms (Multiple paradigms), object-oriented (Object Oriented Programming) is still its most notable feature. Similar to CPP, although there are thousands of principles in product design, the abstraction of requirements is and will remain the most critical preprocessing for product realization for a long time.

insert image description here

2 Why abstract?

Computer science is the science of computers, and computer technology is the technology of abstraction

insert image description here

  • application
  • programming language/runtime
  • operating system
  • processor
  • computing unit
  • Digital Logic/Circuit
  • Physical layout (VLSI)
  • Tape out

In the computer architecture, the designers of each level only need to consider the problems of the next level, and do not need to consider the problems of the next level of the next level. So abstraction is simplification, and abstraction improves efficiency.

3 Why is it necessary to package?

The Nepal Army Knife may have more functions than an electric drill, but what we need is an electric drill

This is the address mapping diagram of a certain processor, from which we can see the address ranges of the two APB buses. All the peripherals on the chip are mounted on these two buses. To operate the peripherals, the developer can use the starting addresses of the two buses as the base address to access the peripherals.

insert image description here

This is the picture on the home page of the C++ Boost library, a red button, embodying the design philosophy of one-click availability.

insert image description here

Of course, this comparison is slightly exaggerated, but good packaging can shield unnecessary details and greatly save developers' energy.

4 What about inheritance?

"Find a path that others have already traveled"

When we solve problems or achieve goals, we should look for methods and experiences that have been successfully explored by others. By drawing on the experience of others, we can avoid repeated exploration and mistakes, and reach our goals more effectively.

insert image description hereinsert image description hereinsert image description here

Taking the operating system as an example, it abstracts the processor into a process/thread, abstracts the main memory into memory management, and abstracts the disk into a file system. We can learn from/reuse these components in the operating system without having to develop them ourselves.

Guess you like

Origin blog.csdn.net/qq_33904382/article/details/132377205