Re: Upgrade Anxiety
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Tue, 08 Jan 2008 00:31:04 -0500
See below...
On Mon, 07 Jan 2008 11:39:50 -0500, David Wilkinson <no-reply@xxxxxxxxxxxx> wrote:
Joe:***
Inline:
Joseph M. Newcomer wrote:
In the entire history of MFC, there has never been a sane reason that handlers and control
variables were ever made public. There was a bad reason: the very weak ClassWizard
parser, but that was not really a good justification for creating bad code. Adding
control variables defaults to "public", which is wrong, and handlers are put in as
"public", which makes no sense whatsoever.
I know you do not like UpdateData() and value member variables, but if
you do use them, then it is useful to make the variables public, because
it allows use of the paradigm
Note that I carefully said "control variables". Data variables make sense for the reason
you point out, but data variables were not part of the discussion. And I have no problem
with using the *implicit* UpdateData calls that happen from OnInitDialog and OnOK
****
****
CMyDialog dlg;
dlg.m_nThis = nThis;
dlg.m_nThat = nThat;
if(dlg.DoModal() == IDOK)
{
nThis = dlg.m_nThis;
nThat = dlg.m_nThat;
}
Not very good OOP, but it allows you to see from the client code exactly
what the dialog does. It even allows simple dialogs to be designed
entirely in the resource editor, without writing any code.
But actual control variables (CWnd derived) should never be public, I agree.
And, as you point out, the fact that it just sort of randomly adds things into the file
instead of putting them in sensible places means that you have to go in and clean up the
header file to group handlers, variables, and so on into what makes logical sense to
someone reading the header file. VS6 had this right, even if it was for the wrong
reasons.
Unfortunately there is no going back now, because there is a lot of code
written without the ClassWizard-delineated sections that kept everything
in the right place.
Sure there is. New markers can be added, and new versions will use those markers. Old
code can have them hand-edited in; if they're there, they are honored; if they are
missing, stuff gets added to the end. Fully upward-compatible! A marker like
protected: //{{Control variables}}
or
public: //{{ControlVariables}}
would work perfectly well. So there is no harm in adding something intelligently
designed, because it will not break existing code, but new code can take advantage of it,
and old code can be modified to support it!
****
****
One of the most annoying things is always putting new DDX.. statements
at the end of the DoDataExchange(), which can mess things up if you have
other code there besides DDX/DDV statements.
Yes, but to do otherwise would have required DESIGN, something woefully absent. As I've
said before, I strongly believe that software evolves, because there is so little evidence
of Intelligent Design in it.
joe
****
Joseph M. Newcomer [MVP]
<snip>
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Re: Upgrade Anxiety
- From: David Wilkinson
- Re: Upgrade Anxiety
- From: Giovanni Dicanio
- Re: Upgrade Anxiety
- From: Joseph M . Newcomer
- Re: Upgrade Anxiety
- From: David Wilkinson
- Re: Upgrade Anxiety
- From: Joseph M . Newcomer
- Re: Upgrade Anxiety
- From: Ajay Kalra
- Re: Upgrade Anxiety
- From: David Connet
- Re: Upgrade Anxiety
- From: Joseph M . Newcomer
- Re: Upgrade Anxiety
- From: David Wilkinson
- Re: Upgrade Anxiety
- Prev by Date: Re: Upgrade Anxiety
- Next by Date: Re: Upgrade Anxiety
- Previous by thread: Re: Upgrade Anxiety
- Next by thread: Re: Upgrade Anxiety
- Index(es):
Relevant Pages
|