Comparing OOP and GP in C++

Comparing OOP and GP in C++

Postby Cuchulainn » Fri Feb 16, 2007 4:15 pm

OO is OK but putting everything in a class hierarchy is not even wrong. There are other possibilities:



C++ is one of the most popular languages for the development of software systems for Quantitative Finance. It is more than 25 years old and it supports the modular, object-oriented paradigm (OOP) and the generic paradigm (GP) in the form of C++ template functions and classes. Most developers are familiar with OOP but a smaller percentage of these developers use C++ templates to design and implement efficient, portable and robust software. There are a number of reasons for this situation some of which are that the syntax of C++ templating can be difficult to understand and second the idea of designing software components using C++ has not been given full justice in the literature. Using templates to design components is similar to how hardware is designed. For example, think about the hardware ports on your laptop; it provides services to other hardware entities and it requires services from other hardware entities. In a similar vein, we are designing the Monte Carlo engine based on similar principles; it consists of a number of plug and socket components. For example, an SDE component provides a set of interfaces for defining and accessing the mathematical description of a stochastic differential equation. It requires data and parameters from a GUI screen, database system and real-time data feed systems. Continuing, a component ?FDM? that approximates the solution of a stochastic differential equation requires the services from SDE and provides services such as discrete paths and other statistics to other components, for example an Excel application. In this sense we build large applications using interoperable building blocks. This idea is called policy-based design using C++ templates.
User avatar
Cuchulainn
 
Posts: 669
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

UML Component Diagrams

Postby Cuchulainn » Fri Feb 16, 2007 4:18 pm

Here is a non-QF examples of balls and sockets contracts in s/w



Image
User avatar
Cuchulainn
 
Posts: 669
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

OOP vs GP

Postby Cuchulainn » Sun Feb 18, 2007 4:33 pm

We wish to emphase that the object-oriented and generic programming paradigms can be combined and they should notnecessarily be seen as competitors. The relationship is as follows: we employ C++ templates to design and specify template components. In other words, we define contracts by specifying the component?s provided and required interfaces at the meta level. Then we can instantiate the component?s generic parameters by specifying, for example pointers to base classes. In this way we combine reliability and robustness at the meta level with dynamic run-time behaviour at the class level. In short, we are implementing parametric and subtype polymorphism, respectively. We thus draw a distinction between a type (for example, a template class) and a class (for example, a instantiated template class). It is the best of both worlds as it were.



The process of design is as tangible as that of coding. In Mechanical CAD - for example - one designs an object with enough information that it can be directly machined. A similar process with Template Meta Programming in software. We program at two different levels.
User avatar
Cuchulainn
 
Posts: 669
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Cuchulainn » Sun Apr 25, 2010 10:01 pm

Here are policy-based factories
Attachments
GenericCreator.cpp
(1.69 KiB) Downloaded 538 times
User avatar
Cuchulainn
 
Posts: 669
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands


Return to C++

Who is online

Users browsing this forum: No registered users and 2 guests

cron