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
 Refactor: Override of a virtual function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mbobka
Ketchup Master

Russia
86 Posts

Posted - Jun 28 2006 :  09:56:29 AM  Show Profile  Reply with Quote
For instance:


class CBaseClass {
public:
    virtual void FuncA();
    virtual void FuncB() = 0;
};

class CDerivedClass: public CBaseClass {
public:

};


It would be cool, if Refactor will have option to override any virtual (or not only virtual fuctions of CBaseClass) in CDerivedClass.

pogothemonkey
Senior Member

31 Posts

Posted - Jun 28 2006 :  10:43:35 AM  Show Profile  Reply with Quote
I love this functionality in Intellij.

It knows which functions are in the superclass, in the subclass I can open a windows that shows me all the functions in the superclass I can overide and the ones that need to be overridden (pure virtual). Next you Select the ones that you want to implement and it will insert the correct function body into the code.

This is exceptionally helpful with pure virtual functions. Moving to C++ it would be great if it inserts the Declaration and a Stump Definition at the same time
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jun 28 2006 :  4:47:41 PM  Show Profile  Reply with Quote
the immediate problem here is that we have to stop and ask the user questions. we cannot simply provide bodies for all such functions, not even abstract functions. after all, derived classes are still going to be abstract.

the current approach is to keep a very low profile, and to avoid asking lots of questions.

i do a lot of work with the Qt framework, and when developing my own GUI components (e.g. a dialog) i will derive myself a class from QDialog, which has lots of virtual functions, to allow me to override any specifics i need to. most of the time i never bother.

applying this thinking to this case i could end up with a list of 20, 30, 50 functions to pick through, perhaps more for some cases.

the flip side is simple data classes, with one or two abstract functions that you always implement.

some of the time i see a lot of appeal to this idea, but other times i can see how this could be quite unhelpful.

i am wondering if there is some sensible way to organise, or hide the GUI for this. any ideas or suggestions based on experience with other products?

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

jpizzi
Tomato Guru

USA
642 Posts

Posted - Jun 28 2006 :  10:51:39 PM  Show Profile  Reply with Quote
Having used frameworks, too, I can see the potential for a long list. However, if the list was triggered explicitly (for example, a right-click, or a hot key), I can't see how it is worse than having no list at all. The list could be restricted to virtual methods, with pure virtuals listed first (a suggestion; I haven't thought this part through). Especially on classes that have methods with numerous overrides, I think this would be especially helpful, as getting the correct parameter list in the override sometimes poses problems.

I added a request.

case=1505

Note that my suggestion was that this be from an explicit request from the user, and that the user must select the method to override. Nothing automatic up until that point. After that, add the stub and declaration.

(edit by feline: fix case number)

Joe Pizzi

Edited by - feline on Jul 01 2006 11:40:38 AM
Go to Top of Page

bugfix
Tomato Guru

Germany
324 Posts

Posted - Jun 29 2006 :  02:11:10 AM  Show Profile  Reply with Quote
If you decide to do it please make sure that it'll work w/ template classes as base too, e.g. ATL/WTL.

-bugfix

http://www.mf-sd.de
Go to Top of Page

mbobka
Ketchup Master

Russia
86 Posts

Posted - Jun 30 2006 :  02:07:37 AM  Show Profile  Reply with Quote
I think here needed two ways to be implemented.
1. Overriding any virtual funciton
2. Implementing all pure virtual functions of specified base class (for fast interfaces implementation)

First way, requires list of functions one of which you want to implement.
Second way can be done absolutely automatically.

I want to describe as I see second way implementation.
We have:

class ISomeCoolInterface1 {
public:
  virtual void Function1() = 0;    // this function must be implemented through autoimplementation
  virtual void Function2() {};     // this function not be implemented through autoimplementation

  void Function3();     // this function never be overriden by refactor
}

class ISomeCoolInterface2 {
public:
   virtual void Function10() = 0;
   virtual void Function11() = 0;
   virtual void Function12() = 0;
}

class CObjectWithTwoInterfaces:
   public ISomeCoolInterface1,
   protected ISomeCoolInterface2
{
public:

};



When I hover on ISomeCoolInterface word in CObjectWithTwoIntefaces declaration VAX should show "down arrow icon" with item in menu "Override pure virtual functions of class ..." (or smth like this)

When I call "Override pure virtual functions of class ..." then the class declaration will be like this:

class CObjectWithTwoInterfaces:
   public ISomeCoolInterface1,
   protected ISomeCoolInterface2
{
public:
public:  // ISomeCoolInterface
  void Function1() override;
};


--- continued below

Edited by - mbobka on Jun 30 2006 02:09:33 AM
Go to Top of Page

mbobka
Ketchup Master

Russia
86 Posts

Posted - Jun 30 2006 :  02:08:43 AM  Show Profile  Reply with Quote
when I call refactor for ISomeCoolInterface2, then refactor adds function and preserves interface visibility:

class CObjectWithTwoInterfaces:
   public ISomeCoolInterface1,
   protected ISomeCoolInterface2
{
public:
public:  // ISomeCoolInterface1
  void Function1() override;
protected:  // ISomeCoolInterface2
  void Function10() override;
  void Function11() override;
  void Function12() override;
};



I think there must be two Autotext template: for entire interface implementation, and second for a implemented function (I want use "override" specifier for the function)

Edited by - mbobka on Jun 30 2006 02:09:02 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 01 2006 :  11:46:04 AM  Show Profile  Reply with Quote
interesting. i have put a note on the feature request about this, and saying that you have posted a good example here.

in your sample code i presume the word "override" is just a comment or marker, and is not supposed to compile?

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

mbobka
Ketchup Master

Russia
86 Posts

Posted - Jul 01 2006 :  11:49:16 AM  Show Profile  Reply with Quote
"override" is a new keyword in VS2005. Can be applied in CRL/C++ and plain/C++.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 02 2006 :  1:40:34 PM  Show Profile  Reply with Quote
it came up in another thread, after i posted here. still, good to have these things confirmed.

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

ralfz
Junior Member

Germany
13 Posts

Posted - Jul 13 2006 :  2:17:57 PM  Show Profile  Reply with Quote
One example for a -well, at least for me- good solution handling the override of virtual functions, is an old Addin for VS6 called "WizGen". It can be found on Codeproject at:

http://www.codeproject.com/macro/wizgen.asp

It assumes, that the current active .h file in VS editor contains the "target" class declaration (the class deriving) and shows a dialog with base class functions to select from. It is possible to select from a combobox the base class to derive from, if multiple bases.

Please take a look at this addin. I always missed that, when working in VS environment > 6.0.

Probably VAX already has all the information needed for a similar dialog. For me personaly, such a feature would be another, if not THAT "Killer-super-cool-Feature" in VAX.

This Addin made it even possible to have a "Class-wizzard" like behavior in VS6, not for just MFC, but for 3rd-party libraries, which should be "Stable includes" in VAX terms.

Edited by - ralfz on Jul 13 2006 2:29:41 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19020 Posts

Posted - Jul 15 2006 :  11:35:49 AM  Show Profile  Reply with Quote
i will put this plugin on my list of things to have a look at. there are no screen shots on the article to help me visualise what it is going to do, or how it is going to do it.

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

support
Whole Tomato Software

5566 Posts

Posted - Jan 24 2011 :  4:04:57 PM  Show Profile  Reply with Quote
case=1505 is implemented in build 1840

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