Skip to main content

Object-Oriented Programming

  • Chapter
  • First Online:
  • 1441 Accesses

Part of the book series: Textbooks on Political Analysis ((TPA))

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

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   54.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   69.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD   109.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    Grok, coined in [1] means roughly “to understand intuitively.”

  2. 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. 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. 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. 5.

    http://en.wikipedia.org/wiki/Median_voter_theorem.

  6. 6.

    http://en.wikipedia.org/wiki/Jefferson_(Pacific_state).

References

  1. Heinlein, R. A. (2014). Stranger in a strange land. London: Hachette.

    Google Scholar 

  2. Schwartz, B. (2004). The paradox of choice: Why less is more. New York: Ecco.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

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

Publish with us

Policies and ethics