Serving the Quantitative Finance Community

 
User avatar
nyamazani
Topic Author
Posts: 0
Joined: February 22nd, 2005, 5:07 pm

C++ question

May 6th, 2005, 1:07 pm

Hi,I am new to the whole idea of object oriented programming, and was wondering in a basic MC simulation (say to calculate the price of a call)what are the objects and what are their methods?is it even necessary to use objects when the whole concept works very nicely in a procedural framework?This is, no doubt, a question bourne out of shameful ignorance, but please could someone enlighten me..Thanks
 
User avatar
marcster
Posts: 0
Joined: July 14th, 2002, 3:00 am

C++ question

May 6th, 2005, 1:37 pm

Hello,no, it is not *necessary* to use objects, especially not in C++ which still contains C as a subset (for legacy reasons) and thus makes it quite possible to write "C++ programs" that have no connection with OO at all.If you use a language like Java, you will need to start out with a class. However, the language again cannot force you to continue designing your program the OO way beyond that, and so procedural programmers end up writing 10,000 line programs which consist of a single class used as a wrapper for a functional program.What I am trying to say is that you will have to see the benefits of OO before you are really going to use it. There is nothing about any computer language that forces you into a clean OO approach.The actual benefits themselves are less clear cut than a mathematical argument. There are C people who have checked OO and decided it is not worth the move. Huge systems (e.g. the Unix operating system) have been successfully implemented in a purely functional way. What I found is that OO looked very much the superior approach once I had played around with it for a while; however it needed to sink in first. I believe that programming is a craft rather than a science.If you are specifically interested in how a basic MC simulation would be done using OO, and what arguments could be made in favour of the OO case, may I suggest Mark Joshi's C++ book which contains precisely that sort of discussion.
 
User avatar
lballabio
Posts: 0
Joined: January 19th, 2004, 12:34 pm

C++ question

May 6th, 2005, 2:32 pm

The point is not whether or not your program uses OO, but whether or not it is modular enough that a) it is understandable by someone reading it---possibly yourself a few months after, b) it can thus be extended without breaking it, and c) parts of it can be reused for different pricers.The reason OO programming is popular is that it can help attaining the above (even though it is of course no silver bullet---it is not in the least difficult to write OO spaghetti, and it takes experience to create good designs.)All of the above can just as well be obtained by means of procedural programming. However, it would be easier to do it in functional languages (either pure ones such as Haskell or impure ones such as ObjectiveCaml) which have support for higher-order functions and closures. Doing it in C (or procedural C++) would likely end up in passing function pointers around, which is not very comfortable.Luigi
 
User avatar
nyamazani
Topic Author
Posts: 0
Joined: February 22nd, 2005, 5:07 pm

C++ question

May 6th, 2005, 2:40 pm

Thanks for your answersI am simply trying to get my head around the design aspects of OO programming in a financial setting.It is all very well trying to learn C++ in a book, but when all the classes are "pets" and "domestic appliances" it is not very helpful.I just want to know how to translate these concepts into a financial setting.I'll have a look at Mark Joshi's book.... it looks like the way forward.
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

C++ question

May 9th, 2005, 2:41 pm

When I introduce OO to C++ programmers I use options. It may be a little basic for what you're looking for, but drop me a PM with your Email and I''ll send you a copy
 
User avatar
mj
Posts: 12
Joined: December 20th, 2001, 12:32 pm

C++ question

May 9th, 2005, 3:14 pm

QuoteOriginally posted by: nyamazaniThanks for your answersI am simply trying to get my head around the design aspects of OO programming in a financial setting.It is all very well trying to learn C++ in a book, but when all the classes are "pets" and "domestic appliances" it is not very helpful.I just want to know how to translate these concepts into a financial setting.I'll have a look at Mark Joshi's book.... it looks like the way forward.I always like think somy book was a reaction to reading too many books with examples on the lines of "a car is a vehicle".
 
User avatar
mutley
Posts: 20
Joined: February 9th, 2005, 3:51 pm

C++ question

May 9th, 2005, 3:51 pm

Haven't yet got it myself but it's certainly on my reading list - quite enjoy teaching myself a language without resting on someone else's programming style though. On a kind-of- side note, I think it's great how recent grads/learners like me can talk directly to authors/experts on this website; that sort of interaction/exposure is great.Mutley