Abstract
There are three major paradigms for designing software: procedural, functional, and object-oriented design. All three approaches use common features such as variables, data structures, and functions. The key difference is in which levels of abstraction are emphasized in each paradigm.
Electronic Supplementary Material The online version of this chapter (https://doi.org/10.1007/978-3-030-36826-5_3) contains supplementary material, which is available to authorized users.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
Grok, coined in [1] means roughly “to understand intuitively.”
- 2.
Note that unlike the previous chapter, many of the code snippets in this chapter begin with line numbers rather than >>>. This is meant to indicate that we expect the code to be saved in Python files, which are plain-text files with a .py extension such as my_code.py. We recommend typing the code into an editor of your choice and running it with a command such as python my_code.py. This will allow you to save your code for later, and to easily edit it if you make any mistakes.
- 3.
Remember that methods beginning and ending with the double-underscore are called “magic methods” and are built into Python. The opposite of an initializer is called a destructor and can be designated with __del__. A very useful magic method is __str__, which defines what will be returned when an object is printed. We will see an example of this in the lab session later in the chapter.
- 4.
In fact you can use any variable name to refer to the instance as long as it is the first argument to the function, but by convention Python programmers use self and so tools such as text editors understand this convention for the purpose of syntax highlighting.
- 5.
- 6.
References
Heinlein, R. A. (2014). Stranger in a strange land. London: Hachette.
Schwartz, B. (2004). The paradox of choice: Why less is more. New York: Ecco.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2020 Springer Nature Switzerland AG
About this chapter
Cite this chapter
Cutler, J., Dickenson, M. (2020). Object-Oriented Programming. In: Computational Frameworks for Political and Social Research with Python. Textbooks on Political Analysis. Springer, Cham. https://doi.org/10.1007/978-3-030-36826-5_3
Download citation
DOI: https://doi.org/10.1007/978-3-030-36826-5_3
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-36825-8
Online ISBN: 978-3-030-36826-5
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)