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
 Refactoring: Add Fields to Constructor
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Curtis
Junior Member

14 Posts

Posted - Dec 12 2007 :  2:48:50 PM  Show Profile  Reply with Quote
When a class is first created, there are several things you do right away:

1. create fields
2. create properties
3. add fields to the constructor for initialization

Add a refactoring to a constructor to "Add Fields to Constructor for Initialization". Then let the developer choose the fields from a dialog (list fields with a checkbox beside) and add the fields to the constructor and initialize them to the default value.

Chief Software Fanatic - www.carverlab.com

mwb1100
Ketchup Master

82 Posts

Posted - Dec 12 2007 :  3:27:23 PM  Show Profile  Reply with Quote
There was a recent request to have VAX create an initialization list: http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=6859

I like the checkbox idea, and I think that even if VAX cannot reasonably determine what the 'default' value for a field might be, just having the field in the initializer list so that I can fill in the actual initial value would be a nice feature.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19024 Posts

Posted - Dec 13 2007 :  3:15:10 PM  Show Profile  Reply with Quote
As mwb1100 says, initializing custom types is very hard. What about structures? Variables where the type comes from a #define?
It is easy to produce real world cases that are very hard to have intelligent defaults for.

zen is the art of being at one with the two'ness
Go to Top of Page

graham.reeds
Ketchup Master

United Kingdom
51 Posts

Posted - Dec 14 2007 :  09:35:38 AM  Show Profile  Reply with Quote
If it can't think of one, do what it does now - not add it.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19024 Posts

Posted - Dec 14 2007 :  10:03:23 AM  Show Profile  Reply with Quote
Is this not going to make things worse? For a class with 15 member variables you might get a random 7 of them initialized, and then need to add the remaining 8, at the correct points, into the list.

zen is the art of being at one with the two'ness
Go to Top of Page

PsiX
Junior Member

14 Posts

Posted - Dec 14 2007 :  10:17:44 AM  Show Profile  Reply with Quote

As was already posted on the other thread and above, it would be nice if VAX could generate the initalizer list even if it can't fill it with meaningful values. Where it can't fill the list, it should leave a comment, but more like this:

X:X(): Base(/* write initializer */), int i(0), void* pPtr(NULL), Complex(/* write initializer */), float(.0f)
{
}



Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19024 Posts

Posted - Dec 15 2007 :  11:36:33 AM  Show Profile  Reply with Quote
I have put in a feature request for this to see what the developers make of it:

case=10622

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