Wednesday, November 17, 2010
c++ design patterns and derivatives pricing (2nd ed)
just finished a nice quant book by mark joshi. still need to go back through the exercises, but it was a nice taste of some basic but real quantitative finance data structures and their c++ implementation, as well as more general c++ and oo issues. here are a few points that i think i should remember:
open-closed principle
open for extension, closed for modification (don't require editing files to extend their functionality)
const
good for discipline, safety, and optimization
rule of three
with no declared copy constructor, the compiler will do a shallow copy
if destructor, assignment operator, or copy constructor is defined, define the other two, too
rule of almost zero
almost never declare any of destructor, assignment, or copy
use smart pointers instead: shared_ptr, scoped_ptr, or Wrapper
to avoid memory leaks
'almost': class with abstract methods is likely to be deleted by pointer to the base class, so it needs a virtual destructor
stlport.org provides an stl with range checking, useful if you're not using visual c++ 8.0 (it already has debug mode)
boost.org is intended to become part of c++ standard
quantlib and xlw
commands never to use
malloc
free
new []
delete []
throw exception: ok in constructor, never in a destructor
new is slow
floating point errors do not cause exceptions by default, but they can be made to
pimpl
private implementation: one class is visible to clients with no data except a pointer to another class, which is defined in the source file in an unnamed namespace
difference between encapsulation and insulation: private changes do not affect classes protected by encapsulation, but fail to insulate because all clients have to recompile
lots of good refs like 7, 11, and 18
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment