O'Reilly logo

Financial Instrument Pricing Using C++, 2nd Edition by Daniel J. Duffy

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 7Multiparadigm Design in C++

7.1 Introduction and Objectives

In this chapter we discuss the integration of modern features in C++ with object-oriented design techniques. The goal is to design robust and flexible classes in C++. We strive to design classes that have a single responsibility and that also have minimal coupling with other classes. In other words, a class should depend on a small set of classes to which it delegates. Furthermore, we discuss how to implement class hierarchies using subtype polymorphism, Curiously Recurring Template Pattern (CRTP), Strategy design pattern and by using a mix of object-oriented and functional programming styles. Instead of having to create class hierarchies with possibly many derived classes we can create a single class that is composed of one or more universal function wrappers (instances of std::function). These functions can be assigned to a range of target methods as described in Chapter 3. We have already seen an example in Chapter 6 (Section 6.8) when we discussed stochastic differential equations. In this sense we note that function wrappers are competitors to virtual functions.

We also give an overview of object-oriented software metrics that measure code quality by providing metrics for classes, their members as well as class hierarchies.

In general, we see objects and classes as important during the detailed design and implementation phases of software development. We do not use them as drivers to decompose a software ...

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