Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Improve "Create Implementation" - Member inits

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 - Jan 19 2010 : 12:53:04 PM
Suggestion (for when you absolutely don't know what else to do ): when we have

// .h
struct Foo
{
   int m_member;
   Foo(int member);
}


"Create Implementation" could give:

//.cpp
Foo:Foo(int member) : m_member(member)
{
}


i.e. automatically add member intialization when "matching" arguments are passed. Of course that should work as well for multiple parameters.

This should extend to other common naming patterns, e.g. member_ / member, member / this->member (I'm not sure if this is valid in an initializer list though...). IMO, match by name is sifficient.

If the initialization is unwanted or incorrect, it is easy to remove or modify - the "important parts" are already in place.


Benefits I hope for:
Member initialization requires repretetive code and - due to the similar symbols - error prone, writing them is fairly annoying. Incremental development and maintenance often add members needing constructor initialization.

What do others think?




"Fallout":
One could also desire automatic initialization of otherwise uninitialized POD members.

Users might argue about different layouts, requiring a format option (e.g. like the other refactoring autotexts)

This could be extended to methods, so that

// .h
// ...
void SetMember(int member)


yields

void Foo::SetMember(int member)
{
   m_member = member;
}


Again, if the initialization is unwanted, it is easy to remove. However, users might then want more elaborate assignments, calling for another autotext, such as

void Foo::SetMember(int member)
{
   if (m_member != member && QueryPropertyChanging(member))
   {
     m_member = member;
     NotifyPropertyChanged();
   }
}

3   L A T E S T    R E P L I E S    (Newest First)
peterchen Posted - Jan 26 2010 : 05:29:51 AM
Looking forward to it! :)
accord Posted - Jan 25 2010 : 1:31:18 PM
I've done a little unintentional parallel work here I've just put in a feature request for this:

case=38674

I'm basically agree with feline, this is not "obvious" and would require additional setup for the coding convention one uses.
quote:
for when you absolutely don't know what else to do )
feline Posted - Jan 25 2010 : 12:38:35 PM
We are considering doing something similar:

case=14340

Is the idea of creating a class constructor that takes parameters for and initializes some of the class member variables. So you would select the member variables you wanted the constructor to initialize, probably via VA Outline, and then VA would generate the relevant constructor for you.

This bypasses the problems of matching the parameters with the members. Sometimes it should be "obvious", but I am always wary of words like that, since what is "obvious" to a person is not always so obvious to a program

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