home.png New Class Dialog Replacement

38236

When you type CREATE CLASS ? in the Command Window, the native New Class dialog pops up and after having filled in only three fields a new class can be created. The required fields are:

1. the class name
2. the class it must be based on; in other words the parent class
3. the classlib that it must be stored in.

That’s all and that’s simple. But I think it is a little bit too simple. Why? It is the class name that troubles me. All text books and all gurus tell us that we must pay special attention to the name of a class. It should be created according to a scheme, a philosophy. For example, the scheme may prescribe that any class’s name starts with certain characters and/or contains a reference to the type of class.

Perhaps you say now: “Agree, but that is possible with the native New Class window, isn’t it? So, what’s your problem!” The problem I see is that it may be hard to understand and/or apply the scheme. Moreover, a developer in your team may show a lack of discipline. Of course, you might consider to fire that developer. But perhaps this person has other talents that you highly appreciate.

In the long run a myriad of inconsistent class names may have been created. By that time the names in your classlibs appear to be a mess and you start to have problems remembering their purpose.

What I have done is create an alternative New Class dialog that creates the class name, based on some choices. Moreover, there is code that enables us to integrate the dialog in the Project Manager. When the developer chooses New (Class) in the Project Manager, the alternative dialog will be invoked instead of the native one.

The project manager is Peter de Valença, vfpx@viafox.nl

vfpxreleasesmall.png Latest Release of New Class Dialog Replacement

Last edited Nov 9, 2009 at 8:20 PM by DougHennig, version 5

Comments

bbout Nov 13, 2009 at 1:57 AM 
Document states that there is no way to get the filename when adding a class. While this is true from the project hook, when you use VFP it knows the current file name. So if you highlight a class and select NEW it knows the name of the classlib.

I am sure that there is a way to also know the filename. It will be something to do with trapping messages using BindEvent., since the treeview is just another window in a window as this image shows. In the image, the treeview and its containing window have been moved. So I think a solution would be to Bind to this window and trap the clicks. Can this actually work? I don't know.
http://www.foxite.com/uploads/99a812ff-f8b2-43bc-8314-ba6a17974600.jpg