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();
}
}