Chapter 6. Object-Oriented Programming

The purpose of software engineering is to control complexity, not to create it.

Pamela Zave

Object-oriented programming (OOP) is one of the most popular programming paradigms today. Used in the right way, it provides a number of advantages compared to, for example, procedural programming. In many cases, OOP seems to be particularly suited for financial modeling and implementing financial algorithms. However, there are also many critics, voicing their skepticism about single aspects of OOP or even the paradigm as a whole. This chapter takes a neutral stance, in that OOP is considered an important tool that might not be the best one for every single problem, but that should be at the disposal of programmers and quants working in finance.

With OOP, some new language comes along. The most important terms for the purposes of this book and chapter are (more follow later):

Class

An abstract definition of a certain type of objects. For example, a human being.

Object

An instance of a class. For example, Sandra.

Attribute

A feature of the class (class attribute) or of an instance of the class (instance attribute). For example, being a mammal, being male or female, or color of the eyes.

Method

An operation that the class or an instance of the class can implement. For example, walking.

Parameters

Input taken by a method to influence its behavior. For example, three steps.

Instantiation

The process of creating a specific object based on ...

Get Python for Finance, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.