Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keep track of Classes

Status
Not open for further replies.

Koen Piller

Programmer
Jun 30, 2005
841
NL
Hi,

I am enjoying an application "Keep track of your bitmaps" which I can advise anybody working with VFP applications with lots of graphics.

Just wondering if there is a similar applications for classes in your project?

I would like to clean and repair my project on obsolete classes. Also facing a problem my project insists on adding a non-exsisting class. In order to built the project I have added a non-functional class with the name, my project is looking for.

A 'Keep track of your classes' application might help me with this nasty error.

Jockey(2)
 
This might interest you as a best practice white paper. It doesn't directly address your problem, though:

Steven Black also has written a share.prg plugin to the class browser, enabling to put a class and all it's parent classes in a vx for sharing, repointering all the dependencies so all classes end in a single vcx to easily share.

The code of that would also be good to program a 'keep traack of your classes'

And indeed it's easy to find out a parent class, reading vcxes as DBFs.

Class is in Objname field, Parentclass is in Class field and Parent Class location is in Classloc.

The nomenclature looks odd, but makes sense if you take into account a class "myform" based on "form" is a form class, only classes inheriting "myform" would be "myform" classes, though "myform" also is a myform class, the original myform class.

Classloc contains a relative path in most cases, which you can apply to DBF() via Fullpath(Classloc,Dbf())

So from a class record you can find the parent class and it's location.

Bye, Olaf.
 
Jockey,

I am enjoying an application "Keep track of your bitmaps" which I can advise anybody working with VFP applications with lots of graphics.

Would that be my Review Bitmaps utility (Keep track of your application's graphic files)? If so, I'm pleased you find it useful. In theory, it should be possible to adapt it to work with classes (at least, VCX-based classes); I'll have to think about that.

If it is from somewhere else, perhaps you could post a link.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Hi Mike,

No of course it is your splendid class. You dont know how helpfull this little thing is. Specialy when you are dealing with an application which requires lots of graphics and you need to review your graphics to see the overall look. I am now able to load n versions of the same colored object into my project, dont have to worry about the number, when finished in a few minutes your Keep Track cleans everything. A truly marvelous tool.

If you would be able to extend this tool with a "Keep track of your classes" that would be great. Although classes are different than bitmaps, since bitmaps are individual files and classes belong to library files.

Thanks again.

Jockey(2)
 
Jockey,

I might have spoken too soon.

I was thinking I could search for references to VCX files, in the same way as I do for BMPs, ICOs, etc. But, of course, it's possible to reference a class within a VCX without specifying the full file name, for example is a SET CLASSLIB, so that wouldn't work. Also, it wouldn't work with PRG-based classes.

You might like to take a look at Rick Schummer's site ( His HackCX utility might possibly serve your needs. Or, if not, he might have something that does.

In any case, I'm pleased you like Review Bitmaps. Did you know that it's not just useful for VFP apps? I've started using it to keep track of the images in a website.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Getting the list of classes in a prject is easy, the harder problem is to identify which aren't used.

Open your project and execute this:
Code:
Create Cursor curProjectClasses (mVCXFile M, cClass C(128), cInheritsFrom C(128), cBaseclass C(128), mParentClassVCXFile M)
Local ii
With _vfp.ActiveProject
   For ii = 1 To .Files.Count
      If .Files(ii).Type = 'V'
         Use (.Files(ii).Name) Alias vcxClasslib In Select("vcxClasslib")
         Select vcxClasslib
         Scan For !Empty(vcxClasslib.Class) ;
              And !Empty(vcxClasslib.Objname);
              And  Empty(vcxClasslib.Parent)

            Insert Into curProjectClasses Values;
               (Upper(.Files(ii).Name) ;
               ,vcxClasslib.objname ;
               ,vcxClasslib.Class ; 
               ,vcxClasslib.BaseClass ;
               ,Upper(Iif(Left(vcxClasslib.Classloc,1) $ ".\" ;
               ,          Fullpath(vcxClasslib.Classloc,.Files(ii).Name) ;
               ,          vcxClasslib.Classloc)) ;
               )
         Endscan
         Use In Select("vcxClasslib")
      Endif
   Endfor ii
Endwith

Now look into datasession window, the curProjectClasses will list all classes, beginning with their vcx file, their name, then their parent classs they inherit from, their base class and the parentclass VCX File, where the inheritfrom class can be found.

The project is incomplete, but would grow by a build, if some mParentClassVCXFile would not be part of the cursor in the VCXFile field of any other record Iincluding the same, if parent classes are in the same VCX of course). You won't need to check that, because VFP does autoadd these missing libs to the project, unless they are not found. So what you could check if you find all the files: BROWSE FOR !FILE(mParentClassVCXFile)

The next step would be to analyse any file for usage of classes, eg check out all form controls of forms etc. to see what of the project classes is really used.


Besides: Actually as you should already know, because that's also what we recommended in regard of pictures, IIRC:

If you start a new project, add the main.prg and compile, all related files are added to the projct by the build process, so you get a minimum project this way, too.

Bye, Olaf.
 
Hi Mike,

No of course it is your splendid class. You dont know how helpfull this little thing is. Specialy when you are dealing with an application which requires lots of graphics and you need to review your graphics to see the overall look. I am now able to load n versions of the same colored object into my project, dont have to worry about the number, when finished in a few minutes your Keep Track cleans everything. A truly marvelous tool.

If you would be able to extend this tool with a "Keep track of your classes" that would be great. Although classes are different than bitmaps, since bitmaps are individual files and classes belong to library files.

Thanks again.

Jockey(2)
 
Mike,

Uuug, it is a wonderful application, but that is not the reason why my answer is published twice. Must be some hickup by FireFox - should blame someone else, shouldn't I?


Olaf,

thanks for the starting code. Will have to figure out how to make a list of the non-used classes.

Thanks for sharing,


Jockey(2)
 
Mike Lewis said:
But, of course, it's possible to reference a class within a VCX without specifying the full file name, for example is a SET CLASSLIB, so that wouldn't work. Also, it wouldn't work with PRG-based classes.

Yes, that's the problem. And VFP's build is making a fine job finding out what vcxes it needs, even if they are not part of the pjx yet. It must analyse the SET PATH, SET CLASSLIB and SET PROCEDURE made additional to CREATEOBJECT(), NEWOBJECT() function calls, .AddObject() .NewObject() method calls and also classes added to forms, etc as sub objects to find out what is used.

Maybe it would help to use SCCTEXT.PRG on VCXes, Forms and such binary project filea, just to have everything in text files you can search for class names. This would be a start for finding obsolete classes, when they are not even mentioned in some comment. Still you have to see that you find each class at least once in it's own definition, which can't be count as usage of the class.

@Jockey,

I do use this class list to find double used class names, actually, this already has bit me twice and cost some time to figure out, why some change to a class never is seen in debugger, because there was another class with same name that was created instead.

Bye, Olaf.
 
One strategy for cleaning out garbage from a project is to create a new project, add the main program and Build Project. Unless you have indirect references in the project, anything not included at this point is extraneous.

Unfortunately, you can still end up with some files that aren't actually used. But it's a start.

If you get FoxRockX, check out my article from the May 2011 issue. I published a class with a bunch of tools for working with projects.

Tamar
 
Yes, Tamar

I also said:
If you start a new project, add the main.prg and compile, all related files are added to the projct by the build process, so you get a minimum project this way, too.

And this also only puts used images into the pjx.

Still I'd always feel uncomfortable with such a new pjx. If you include other files, eg Docs for documentation only, or anything else not compiled, the new pjx might not end up as you're used to and as you need.

And as you say yourself, you still could end up with unused classes or libs, just because some class really used is in a classslib, which has other unused classes in them, which in turn point to parent classes in further classlibs, and those are added to the pjx, even though these parent classlibs are as unneeded as their childclass.

I think if you use some ffc class you can get this ripple effect of adding much of the ffc libs into your project, though unused.

Bye, Olaf.
 
Olaf - sorry, I missed that you'd already suggested starting a new project.

Even if you don't really want to use the new project, it's a good way to see what your candidates for unused classes are. It gives you a place to start poking around.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top