Author |
Topic |
|
modulus
Starting Member
1 Posts |
Posted - Aug 02 2013 : 12:01:50 PM
|
Constructor initialization lists are a pain to maintain. The order of initialization should match the order of the members in the class definition. Usually I dont need to put all members in the initialization list, so when adding a new member I have to manually determine the order -- it's very time consuming. Another problem that crops up is making sure each member is initialize properly. I think VAX could help here, and wouldn't be too dificult.
Usage: Right click on constructor -> Refactor -> Update Initialization List ... - A dialog box appears showing all members with a check by ones already in the initializer list. You can check the members you want to add, and VAX updates the code for you:
MyClass() : MyBase(), mMember1AlreadyHere(...), mMember2AddedByVAX(/*TODO:Initialize*/), mMember3AddedByVAX(/*TODO:Initialize*/), mMember4AlreadyHere(...) { }
Even if you get the formatting wrong, it would be a huge timesaver. Just seeing the list of members not initialized is valuable on its own. |
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - Aug 04 2013 : 07:49:18 AM
|
We are considering to implement a refactoring command like this, creating a constructor initializer list from member variables:
case=10622
I have added a comment to the case explaining that it could be used to update the list with new members as well, leaving the old ones (and its values) alone, but maintaining the same order as the members have in the class declaration list. |
|
|
jwiesemann
Junior Member
14 Posts |
Posted - Dec 29 2014 : 04:28:07 AM
|
You should really implement this. Including the update function. This is not only a convenience feature but with an easily implemented initialization list in correct order the chance for uninitialized members will be much lower. |
|
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
|
|
Topic |
|