Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 thought: create member initializing constructor

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
peterchen Posted - Jul 29 2008 : 05:16:52 AM
Note: this is just an idea, please be gentle ;)

something that irks me is this:


class Foo
{
private:
  bool m_bSomeFlag;
  CString m_dfltStr;

public:
  Foo(bool someFlag, CString dfltStr) :
    m_bSomeFlag(someFlag), m_dfltStr(dfltStr)
 { ... }
};


adding/changing one variable declaration that needs such a CTor init requires three places to edit, all with variations of the name.

How VA could help:

Idea 1:
select multimple data members, and provide refactoring option "create initializing constructor". A new constructor is added.
The name of the arguments can be determined from the member names (e.g. stripping m_ or appending underscore).

IMO Default parameters and parameter modifiers are added easily afterwards, so no additional input is needed.

Idea 2:
Add a refactoring option for cosntructors: "Add Member initialization". after some selection of available member(s) (text input? list?), a parameter and the member initialization is added to the constructor. Example:


Foo()
{...}


"Add member initialization for: m_bSomeFlag" changes that to:


Foo(bool bSomeFlag) :
  m_bSomeFlag(someFlag)
{...}


I'd prefer the first one - it is simpler an less cases to deal with, but the second one seems a tad more powerful.

Thoughts? Other ideas? Declarations of craziness?



1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Jul 29 2008 : 11:00:45 AM
For idea number 1, we are considering something like this:

case=14340

For idea number 2, have a look at this forum thread, its not quite the same idea but it is close:

http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=7049

and it raises a couple of relevant concerns about doing this correctly / safely.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000