O'Reilly logo

Python for Finance, 2nd Edition by Yves Hilpisch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 class 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 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 an abstract class.

Translated into ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required