Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Inheritance by copy and paste

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Holi Posted - Aug 30 2007 : 12:21:32 PM
Hi

I often thought that it would be so nice to be able to copy methods from one class to another and having the scope adapted to the new class automatically.

Example:

CMyBaseClass::AnyVirtualMehtod()
{
  TRACE("Trace related to CMyBaseClass");
  // Comment related to CMyBaseClass
}

copy/paste in the new class (derived or not, shouldn't matter) automatically pastes the following code:

CMyDerivedClass::AnyVirtualMehtod()
{
  TRACE("Trace related to CMyDerivedClass");
  // Comment related to CMyDerivedClass
}

or

CMyNewBetterClass::AnyVirtualMehtod()
{
  TRACE("Trace related to CMyNewBetterClass");
  // Comment related to CMyNewBetterClass
}

I guess this wouldn't be too much of a problem, as I think the parsed information should already provide data like this.
3   L A T E S T    R E P L I E S    (Newest First)
support Posted - Jan 24 2011 : 4:04:38 PM
case=1505 is implemented in build 1840
sl@sh Posted - Aug 31 2007 : 04:21:52 AM
Depending on what you do or want, replacing a class name within a TRACE, comment, or any command inside a function may not be correct, even if you move that function to a different class!

I am under the impression what you really want is some kind of intelligent cut&paste that does the hard work (adapting to the new context) for you. Unfortunately anything you might consider a logical adaption for the kind of code you are looking at might be unexpected for other people - and vice versa.

I do not think that it would make sense to make a tool 'guess' at what you want to be adapted and how - there are a million and one possible behaviours, and I guarantee that whatever you define as 'default' will make some people somewhere cry out 'foul!'.

In a situation like this, what I usually do, is use find/replace or better yet, 'Refactor Rename' to replace whatever I need replaced in a controlled way, then move the function. (or first move, depending on how much I expect the old or the new class's context to get in the way). When using Refactor Rename it is often helpful to first erase the 'MyClass::' bit from the function to avoid replacements within other functions of the class.
feline Posted - Aug 30 2007 : 2:12:56 PM
We are considering a related idea. The idea is to sit in a derived class and ask VA to implement the virtual functions from the base class that you select:

case=1505

I don't really follow your example. To add or change the class name before the function name VA would have to know which class you were pasting the function into. But to do that you need to paste the function declaration, or inline implementation, into the class declaration. If the code is in the class declaration then you don't need to add the class name.

Once you have copy / pasted the declaration into the derived class you can simply use VA's Create Implementation refactoring on it.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000