Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 thought: create member initializing constructor
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peterchen
Tomato Guru

126 Posts

Posted - Jul 29 2008 :  05:16:52 AM  Show Profile  Reply with Quote
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?



feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Jul 29 2008 :  11:00:45 AM  Show Profile  Reply with Quote
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.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000