Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Refactor Export Class

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
sl@sh Posted - Aug 27 2007 : 08:48:34 AM
Currently I am busy trying to adopt parts of a project's base structure to up-to-date techniques. What I have are heaps of structs and functions. What I want is a hierarchical structure of classes and methods.

The problem I have is that I cannot afford to just throw everything away, I need to do a gradual change. This means my first steps usually consist of changing the keyword 'struct' to 'class', provide getters and setters (not all, just those that make sense), and let the compiler tell me where the problems are.

Once I am at the stage that a newly converted class works, I would like to 'export' it into an individual file - for one to cut it's ties to dozens of other structs and function declarations that share the same header, and also to make sure I've covered all the dependencies (and of course because I consider it bad style to put more than one class into one header/implementation file).

The problem I have at this point is that VS 2003 does not provide helpful functions for that task: first, it always wants to put the class header and implementation files into my project's base folder (and that, exactly, is the place I want none of the files except for some chosen few), and changing the folder alone is a PITA! Second, if I try to create aclass using file names to match the class name, VS tells me that a class of that name already exists! (of course it does - that's why I want to create those files in the first place!). Alternately I can create a new header and implementation file seperately, doubling the number of steps needed (again, changing the directory is a PITA. Twice!).

People might suggest that I should create the class files before I even change the struct to a class, but unfortunately that wouldn't work very well - for one I often change class names as an afterthought, and changing the according file names appropriately is - you might guess it - another PITA. What's more, it sometimes turns out that I need to split up a struct into several classes, or combine several structs into one. For that reason I defer creation of the actual class definition files to a point where I'm sure the class is mostly final.

The solution I am hoping for would be a new refactoring method from VA. I would require something that enabled me to shove a class definition from an existing header file to a newly created one, preferably matching the name of the class, and within a directory I am able to choose in a reasonable way (i. e. not the way the VS dialog handles this: it only lets you type in the complete path or choose an already existing(!) file(wtf?) with the help of a file dialog). At the same time, shoving class method definitions from an existing file to a newly created one (again, using the class name) should be available aas a refactoring method. I realize the latter will be harder, but maybe it could be realized using VA Outline.

Sorry for the long post, but this is an issue that really bothers me - even to the point that I decided to spend halve an hour writing all this...
7   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Aug 29 2007 : 12:59:04 PM
A good idea
sl@sh Posted - Aug 29 2007 : 04:03:30 AM
Thanks for the link. This tool looks very promising, it even supports TortoiseSVN's custom icon overlays I'll definitely give it a try.

Maybe you should copy this to the 'Lounge'? (or I might, once I've seen it in action)
feline Posted - Aug 28 2007 : 08:25:22 AM
You have my sympathies, I am doing something similar quite often myself.

You may find this useful: http://www.zabkat.com/
I have been looking (on and off) for a decent modern windows explorer replacement for years, and recently found this, which so far does all of the key things I need.

Multiple tabs are proving remarkably useful, since I can keep an eye on 3 or 4 different directories at once, without having to mess around with 4 different windows explorer windows.

If it makes you feel any better I have the "same" solution in VC6, VS2003, VS2005 and VS2008, so I have 4 IDE's to update when I add new files to my solution, while you only have one to deal with.
sl@sh Posted - Aug 28 2007 : 03:19:37 AM
*sigh*
Unfortunately you are right. Just like my professor of Applied Mathematics used to claim, this is another application of the 'law of the preservation of hard work'.
feline Posted - Aug 27 2007 : 3:51:35 PM
Except that you need two file dialogs, since some people do:

C:\\src\\library\\include\\foo.h
C:\\src\\library\\src\\foo.cpp


I have on occasion seen things more like:

C:\\src\\library\\include\\foo.h
C:\\src\\library\\stupid_dir_structure\\src\\foo.cpp

or worse.

I agree that the idea is sensible, and tempting, but I wonder if it is actually easier? With a half decent file manager and a bit of drag and drop it is quite quick and simple. My one project inside my test solution (currently has 6 projects in it) looks like this:



so where to put the files on the hard drive is only half the problem. Where to put the files into the solution is the next problem.
sl@sh Posted - Aug 27 2007 : 12:38:39 PM
Thanks for your suggestions.

Regarding source control - in this context it is not a problem since the files in question would be new anyway. Renaming a file that already is tracked by source control however cannot be done from within the IDE anyway - even if I were using VS 2005.

Using some dummy files and dragging and dropping via file manager (i. e. Windows Explorer) indeed sounds a bit less awkward. At least I expect this method to be less error prone.

I still think VA could implement this within reasonable limits. The question as to where (which directory) should be answered via a 'file' dialog prompting the user to select the target directory.
feline Posted - Aug 27 2007 : 11:38:46 AM
VA creating / renaming files has come up before, just not quite in this exact context.

The main concern over this is the whole question of source control systems, and the directory layout. A lot of people have the header files in one directory and the matching cpp files in a different directory, and then further have various folders within Solution Explorer, to further group and organise the code.

I know this, my main test VA project is organised just like this.

So I have often found myself facing similar problems to you.

*sigh* the fact you are using VS2003 complicates matters a little bit. I normally face this problem in VS2005, where it is a little easier. In VS2005 you can select a file in Solution Explorer, press F2 and simply rename the file in Solution Explorer. When you do this the IDE actually renames the file on the hard drive at the same time. Of course this does not work in VS2003.

What I do personally is I have a pair of "dummy" files. A header file with #pragma at the top and a matching cpp file that includes its single header.

I then copy / paste the pair of files, drop them into the correct directory using windows explorer (normally a decent replacement), rename then, stick them where I need them in Solution Explorer (drag them from windows explorer into the IDE) and then just use them.

This does not sound as simple as what you are after, but you may find that it is actually easier, since a proper file manager is going to be much better for moving around the directory tree than a standard "pick the directory" dialog box. For me the key steps are having some dummy files on hand to copy and rename, and then dragging them into the IDE, bypassing the whole problem of hunting through the directory tree with the IDE's "add file" dialog.

One "interesting" fact, the whole problem "goes away" in C#, since you don't get any control over the file positions, they have to mirror solution explorer, and the IDE makes sure they do. Very much a mixed blessing in my considered opinion.

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