This notebook contains an excerpt from the An Introduction To Python Programming And Numerical Methods For Scientists and Engineers; the content is available on GitHub.

The text is released under the CC-BY-NC-ND license, and code is released under the MIT license. If you find this content useful, please consider supporting the work by buying the book!

< Chapter 6 Summary and Problems | Contents | 7.1 Introduction to OOP >

Object Oriented Programming (OOP)


Motivation

Many times in our work, we need to use some other packages, such as the scipy, numpy and some other domain specified packages. When you check the source code of these packages, you may see some new keywords in the code, such as class that make you wondering what are the classes and why do we use them? This is a new programming paradigm - Object-Oriented Programming (OOP) that is commonly used in writing large programs or packages. When we are writing a large program, the OOP usually have the advantage of making our code simpler for better readability and describe the world, reusable, and smaller amount of bugs. Thus you will see it in most of the standard packages in the field. Therefore, understand the basics of OOP will help us to learn from many source code and to write better code in our programs. In this chapter, we will introduce the basics of OOP, especially the core components: object, class, and inheritance. Python is a highly object-oriented and understanding these concepts will help you a lot in the long run.