November 6th, 2010, 7:38 am
QuoteOriginally posted by: renormAll that makes perfect sense. But Observer is a foundation of almost every class in QuantLib. Decoupling things from it is not possibleQuotewithout total rewriteIt is not about Observer alternatives, it is all about not breaking the legacy code. Observer interface is used in hundreds of source files.Around 1993 I worked in what was probably the first risk C++ system from a s/w vendor. The Observer pattern took centre stage. The two base class were derived from a Watchable object and its Observer. Then the class hierarchy went down the rabbit hole as it were to prodce a 6-deep hierarchy. Almost impossible to maintain, let alone document.So, what's the real problem with Observer? Well, OO Observer defines 2 classes Observable and Observer to model roles. Now roles are objects and dynamic while classese are static. So we model objects as classes.. Soon it breaks up.With Observer an object can only play one of the roles (unless you start messing with multiple inheritance which is the forbidden quarter). Just because (almost) everyone uses it does not mean it's correct. Microsoft stopped using it and now use Delegates. Boost Signals is a breath of fresh air.My solution wth Observer is @outrun's Husqvarna pruning suggestion
Last edited by
Cuchulainn on November 5th, 2010, 11:00 pm, edited 1 time in total.