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
 Implement virtuals
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Alexis Pautrot
Junior Member

21 Posts

Posted - Apr 12 2011 :  05:05:56 AM  Show Profile  Reply with Quote
It should be helpful to have an action named "Implement virtuals", available on a right click on a class inheritance declaration ( class A : public B, public C ) that allow to implement virtual methods of inherited classes. This feature should open a checklistbox to ask which method to override, then implements them in the class.

feline
Whole Tomato Software

United Kingdom
18746 Posts

Posted - Apr 12 2011 :  10:54:42 AM  Show Profile  Reply with Quote
Are you aware of the new Implement Interface refactoring command? This is designed to help in exactly this type of situation.

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

gerol80
New Member

Germany
3 Posts

Posted - May 12 2011 :  08:08:32 AM  Show Profile  Reply with Quote
Hi everybody,

unfortunately this "Implement Interface" command has some drawbacks IMHO:

1. The order of the methods is totally random G?? in the header and the cpp file. It's neither the original order from the interface header nor is it any observable order at all (e.g. alphabetical).

2. It only implements methods from a direct base interface.
Example:
You have an interface IThing. You have another interface IMoreSpecificThing which implements IThing. If you now write a class that implements IMoreSpecificThing and use the "Implement Interface" command, it only implements the methods from IMoreSpecificThing, not the ones from IThing.

Will this command be improved in later releases?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18746 Posts

Posted - May 12 2011 :  2:23:39 PM  Show Profile  Reply with Quote
Point 2, we are working to enhance this command so that it will scan more than one base class deep:

case=52138

This has always been the plan, but it brings its own set of edge cases with it.

Point 1, for the header file, do you have a preference / expectation of the ordering of items? It is complicated by the need to try and respect the visibility of each of the virtual methods.

For the placement into the cpp file, this is something we are looking at, but since the .h and cpp files are often very differently ordered to begin with, it is a little tricky.

Are you aware you can use VA Outline to drag and drop items, to reorder both the .h and the cpp file?

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

gerol80
New Member

Germany
3 Posts

Posted - May 13 2011 :  07:20:03 AM  Show Profile  Reply with Quote
Hi feline,

thanks for your answer. I'd expect the order to be the same as in the header file of the interface I'm implementing. If a class implements several interfaces, you could add comments to separate the methods, e.g.

// Methods from Interface1.h

..........

// Methods from Interface2.h

..........

and so on.

I was not aware of this VA outline functionality. I will try this, thanks!
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18746 Posts

Posted - May 13 2011 :  5:25:29 PM  Show Profile  Reply with Quote
Are you seeing this ordering problem when using system / library classes as your base class, or only when using your own classes as the base class?

I have tried the following, very simple, test here, and the ordering of the implemented functions is the same as the ordering in the two base classes:

class testInterfaceBaseOrderOne
{
	virtual void BaseOneMember1();
	virtual void BaseOneMember2();
	virtual void BaseOneMember3();
	virtual void BaseOneMember4();
};

class testInterfaceBaseOrderTwo
{
	virtual void BaseTwoMember1();
	virtual void BaseTwoMember2();
	virtual void BaseTwoMember3();
	virtual void BaseTwoMember4();
};

class testInterfaceOrderCreated : public testInterfaceBaseOrderOne, testInterfaceBaseOrderTwo
{
};


So I am wondering what is triggering this random ordering of new functions. Does the order of the functions in the dialog seem to be related to the order of the functions as implemented in the header file?

The documentation for VA Outline is here, in case you are interested:

http://www.wholetomato.com/products/features/vaoutline.asp

zen is the art of being at one with the two'ness

Edited by - feline on May 13 2011 5:26:09 PM
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Jul 20 2011 :  02:06:27 AM  Show Profile  Reply with Quote
Maintaining declaration order in Implement Interface is case=58301, and is fixed in build 1854.

Whole Tomato Software, Inc.
Go to Top of Page

tlesher
New Member

2 Posts

Posted - Aug 05 2011 :  11:21:25 AM  Show Profile  Reply with Quote
Great feature.

One suggestion: right now, the body of the function looks like this:


void MyClass::MyFunction()
{
    throw std::exception("The method or operation is not implemented.");
}


When doing TDD or other incremental development, it's not uncommon for this exception to actually get thrown in a test run (until the method actually gets implemented). It would be more useful if the body looked like this:


void MyClass::MyFunction()
{
    throw std::exception(__FUNCTION__ " is not implemented.");
}


Most unit test libraries will print the what() of the exception thrown, which helps when a method that you didn't think should be getting called yet really is.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18746 Posts

Posted - Aug 05 2011 :  1:42:51 PM  Show Profile  Reply with Quote
The method body comes from the VA Snippet "Refactor Create From Usage Method Body". So just edit this snippet to change the exception string:

http://www.wholetomato.com/products/features/vasnippets.asp

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

tlesher
New Member

2 Posts

Posted - Aug 05 2011 :  1:46:31 PM  Show Profile  Reply with Quote
quote:
Originally posted by feline

The method body comes from the VA Snippet "Refactor Create From Usage Method Body".


Ahh, I didn't make that connection when I was looking for the snippet, so I thought it was internally defined.

Thanks!
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18746 Posts

Posted - Aug 05 2011 :  2:08:56 PM  Show Profile  Reply with Quote
Some of the refactoring snippets are re-used for a few different commands, so it is often worth having a look at the snippets, to see if any of them are being used

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

support
Whole Tomato Software

5566 Posts

Posted - Aug 09 2012 :  01:49:17 AM  Show Profile  Reply with Quote
case=52138 is implemented in build 1912

Whole Tomato Software, Inc.
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