Re: [QuantLib-svn] SF.net SVN: quantlib: [10329] trunk/QuantLib

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [QuantLib-svn] SF.net SVN: quantlib: [10329] trunk/QuantLib

Luigi Ballabio
On Mon, 2007-04-23 at 06:19 -0700, [hidden email] wrote:

> Revision: 10329
>           http://quantlib.svn.sourceforge.net/quantlib/?rev=10329&view=rev
> Author:   giorfa
> Date:     2007-04-23 06:19:45 -0700 (Mon, 23 Apr 2007)
>
> Log Message:
> -----------
> floater range accrual added
>
> Added Paths:
> -----------
>     trunk/QuantLib/ql/cashflows/rangeaccrual.cpp
>     trunk/QuantLib/ql/cashflows/rangeaccrual.hpp

Hi all,
        just a few notes. They're not intended to bash the unfortunate
committer of these particular files (which just happened to be the
latest one) but rather to point out a few common mistakes that we all
let slip in the code from time to time, and that can be avoided with a
bit of attention. So:

> Added: trunk/QuantLib/ql/cashflows/rangeaccrual.hpp
> ===================================================================
> +
> +#include <ql/TermStructures/Volatilities/smilesection.hpp>
> +#include <ql/Indexes/iborindex.hpp>
> +#include <ql/CashFlows/all.hpp>

The above won't compile under Linux or Mac OS X. All folder names are
now lowercase.


> +    //! RangeAccrualFloatersCoupon
> +    /*!
> +
> +    */
> +     class RangeAccrualFloatersCoupon: public IborCoupon{

Just repeating the name of the class is not very useful as a comment. It
will show up in the reference manual as:

RangeAccrualFloatersCoupon:   RangeAccrualFloatersCoupon

It might work as a placeholder, but we all know that we won't come back
to expand it once the class works...


> +      public:
> +          
> +        double startTime_;                               // S
> +        double endTime_;                                 // T
> +
> +        const boost::shared_ptr<Schedule> observationsSchedule_;
> +        std::vector<Date> observationDates_;                    
> +        std::vector<double> observationTimes_;                  
> +        int observationsNo_;
> +        
> +        double lowerTrigger_;
> +        double upperTrigger_;

These data member are in the public section, but that's not the main
problem. We should use Real, Integer, Size etc. instead of int and
double. This way, the corresponding variables will automatically change
their precision when a user redefines QL_DOUBLE and QL_INTEGER.


> Added: trunk/QuantLib/ql/cashflows/rangeaccrual.cpp
> ===================================================================
> +    RangeAccrualPricerByBgm::RangeAccrualPricerByBgm(
> +            double correlation,
> +            const  boost::shared_ptr<SmileSection>& smilesOnExpiry,
> +            const  boost::shared_ptr<SmileSection>& smilesOnPayment,
> +            bool withSmile,
> +            bool byCallSpread)
> +    :correlation_(correlation),
> +    smilesOnExpiry_(smilesOnExpiry),
> +    smilesOnPayment_(smilesOnPayment),
> +    withSmile_(withSmile),
> +    byCallSpread_(byCallSpread){
> +        
> +    }

Data members should be initialized in the same order in which they're
declared. Not doing so may result in a warning in the best case; in
hard-to-track bugs in the worst case.


> \ No newline at end of file

This is harmless, but still it causes a warning in gcc when -Wall is
enabled.


Thanks,
        Luigi


----------------------------------------

Dealing with failure is easy: work hard to improve. Success is also
easy to handle: you've solved the wrong problem. Work hard to improve.
-- Alan Perlis



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev