2011. 6. 20. 10:49 quantlib/Implementation
Aside: twin classes
interpolated discount와 forward curves의 코드를 보면 interpolated zero-yield curve와 많이 비슷하다는 것을 알 수 있을 것이다. 자연스럽게 의문점이 생각날 것이다: 공통 코드를 추상화하는 것이 가능하지 않을까? 혹은 하나의 클래스 템플릿이 가능하지 않을까?
대답은 각각 yes 와 no이다. 어떤 코드는 template 클래스로 추상화 될수 있다. 그러나 curves는 반드시 세개의 abstract 함수를 구현해야만 한다(discountImpl, forwardImpl, zeroYieldImpl). 그래서 우리는 여전히 공통 코드와 세개의 모든 클래스가 필요하다.
대답은 각각 yes 와 no이다. 어떤 코드는 template 클래스로 추상화 될수 있다. 그러나 curves는 반드시 세개의 abstract 함수를 구현해야만 한다(discountImpl, forwardImpl, zeroYieldImpl). 그래서 우리는 여전히 공통 코드와 세개의 모든 클래스가 필요하다.
'quantlib > Implementation' 카테고리의 다른 글
Aside: a friend in need (0) | 2011.06.20 |
---|---|
TTP: Template template parameter (0) | 2011.06.20 |
Aside: symmetry break (0) | 2011.06.19 |
Aside: evaluation date tricks (0) | 2011.06.18 |
3. Term structure - the shape of things to come (0) | 2011.06.16 |