[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Code review: product editor

From: Evgeniy Tarassov
Subject: Re: [lmi] Code review: product editor
Date: Fri, 2 Mar 2007 11:59:27 +0100

On 3/1/07, Greg Chicares <address@hidden> wrote:
(1) Class template MultiDimTableTypeTraits duplicates lmi's
function template value_cast(). I would much rather use the lmi
(2) I'd prefer to use standard types instead of wx types where
possible. IIRC, wx container types are just synonyms for STL
containers anyway, but the string types are not substitutable.

Sorry for that. MultiDimTableTypeTraits removed and value_cast used
everywhere, where a conversion is needed. wxString is replaced by
std::string where possible. There are however two occurences of
wxString in constructors left untouched for only consistency with wx.
For example rounding_view_editor.hpp
       (wxWindow* parent
       ,wxWindowID id
       ,const wxPoint& pos = wxDefaultPosition
       ,const wxSize& size = wxDefaultSize
       ,long style = 0
       ,const wxString& name = wxPanelNameStr
Do you think it also should be changed to use lmi own types? It left
untouched only for consistency with its wx base class.

A little question which is not related directly to the above.

IIRC it is not advised to add return after a call to fatal_error().
Does it apply to warning() too?
Comments from alert.hpp:
/// fatal_error: Dire runtime problems that prevent the system from
/// performing a requested action running in any reasonable manner.
/// Generally, an exception would be thrown; a gui might catch it,
/// warning: Significant runtime problems that should be brought to the
/// user's attention: the program may work, but not in exactly the way
/// the user wanted. A gui would probably use a messagebox here.

"Generally" (for fatal_error()) and "would probably" (for warning())
and exception will be thrown.

Some existing code snippets from lmi:

       fatal_error() << "Instantiation failed." << LMI_FLUSH;
       throw std::logic_error("Unreachable"); // Silence compiler warning.
       fatal_error() << "Instantiation failed." << LMI_FLUSH;
       throw std::logic_error("Unreachable"); // Silence compiler warning.
           << "Change to increasing death benefit option"
           << " not allowed on this policy form."
           << LMI_FLUSH
               << "Case '"
               << a_StrategyVector[Year]
               << "' not found."
               << LMI_FLUSH
           return 0; // Bogus return--actually unreachable.

Would it be correct to say that it is advised to throw a logical error
after a fatal_error(), and a warning() should be followed by a return
statement? In both cases the reason to add something is that in the
future there could be an implementation which does not throw. The
difference is due to fatal_error() being much less likely to ever let
program flow to return from it, right?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]