SET CLASSLIB opens one or more class libraries to provide access to a collection of classes. Please discuss the pros/cons to having a one-class-per-classlib (VCX) design versus a multiple-class-per-classlib design.
Please sign your posts even if you have to sign with a pseudonym. It makes it easier to be polite to you. Tom Cerul
This is clearly more of a matter of personal preference than anything else.
- The class browser is much faster with only one class in a vcx. It's painful with a really large vcx, which is slowing development -- Mike Yearwood
- The Class Browser has less clutter when moving from a child class to a parent class, only the parent class is shown. -- Mike Yearwood
- The Modify Class dialog box takes one less click. It defaults to the first class in the vcx. -- Mike Yearwood
- One developer per class, not classlib - read team productivity improvements.
- Only include the classes you need into an EXE.
I believe this would be a huge benefit to maintaining an existing system. There would only be certain classes in the project, making it far easier to see actually used classes, instead of seeing every class in a framework. -- Mike Yearwood
- Safer if a classlib gets corrupted
- Easier to share classes with others, without giving away too much. -- Mike Yearwood
- Less duplication of virtually identical or similar functionality-classes/methods by sharing classes. IOW if I have a class with a method to compute # weekdays between two dates and I send my class to to you and you already have a compute # weekdays between two dates functions, your system ends up with two such functions. -- Mike Yearwood
Steven Black or someone created a Class Browser addin that will copy a single class and all its superclasses from one lib to another. -- Bob Archer
I don't understand this. What has this to do with one vs. multiple-class-per-classlib. You send me your MikeYearwood_DateThings.vcx with on class and I add it to my project. Will my KurtGrassl_DateThings.vcx disappear? No, I have two such functions, regardless whether my KurtGrassl_DateThings-class has its own vcx or not.
- - To clarify - if I give you a red lego block, you can see that it duplicates an existing red lego block. Otherwise you'll have to go digging in your lego bags to find if you already have one. You're not supposed to have duplicate functionality. http://c2.com/cgi/wiki?OnceAndOnlyOnce and http://en.wikipedia.org/wiki/One_and_only_one. -- Mike Yearwood
- Never have to refactor to move a class from one multi-class classlib to a new common classlib for sharing with another project. Another productivity improvement. -- Mike Yearwood
- Takes less time to compile one small classlib - which is beneficial while writing code versus recompiling a large classlib of arbitrarily grouped classes. -- Mike Yearwood
- If there is an error in a class in a vcx, the project manager only reports the classlib name. The more classes, the harder it is to find the error. -- Mike Yearwood
- The IDE occasionally packs the vcx, which is noticeable delay when saving with a big vcx. -- Mike Yearwood
- Makes the resulting exe larger because each VCX is added to the exe. However, this is offset by having huge numbers of unused classes added to simple exes. -- Mike Yearwood
- Results in far more classlibs in the project manager. However, if they are all named properly it will not be hard to find a particular class. Imagine you need a ctrBall class. If it is contained in a ctrBall.vcx, you already know exactly which library to open. -- Mike Yearwood
I think it was Steven Black that wrote a little utility called mc() (short for modiclass I assume) that opens a class in the class editor. It uses metadata produced by a form called vcxlist. I use mc() all the time for quite a while now. Not sure where I got it, some book or article or something. -- Bob Archer
- Significant impact on VSS-Project Manager integrated environments. Of course I argue it's best not to integrate VSS and the project manager. -- Mike Yearwood
I think it was also Steven Black who wrote an article on using the Component Gallery rather than the Project Manager. This exposes classes rather than libs. -- Bob Archer
Hi Bob - That does help somewhat, but it does not reduce the exe size. You still end up adding un-needed classes to the exe. -- Mike Yearwood
- The maximum number of characters in a macro-substituted variable is still 8,192. Code like x=SET([CLASSLIB]), SET CLASSLIB TO ..., SET CLASSLIB TO &x is much more likely to choke if the number of class libraries grows exponentially like it would if class libraries held a single file. Workaround that is to SET CLASSLIB TO ADDITIVE as each class is createobjected and you need not remember and reset at all. -- Mike Yearwood
- One developer per classlib, not per class UNLESS source control is involved. Source control merging is not perfect. - On an effectively managed project that shouldn't be the case. Here's how effective management fails. We have to get this bug fix out before noon. Oops. Sorry manager, because we built everything into massive lumps, only one programmer can work on that part and there's too many things involved to allow us to meet the deadline. -- Mike Yearwood. This is not a problem anymore. Now you can do concurrent programming with FoxPro binaries in 2 or more branches using Fox Bin 2 Prg, merge the changes and rebuild the binaries. -- Fernando DBozzo
- There's a demonstrable performance penalty for multiple SET CLASSLIB commands.
- Object instantiation is slowed based on the number of files that must be searched. That only matters at design time. In the exe there is no set of files to be searched. -- Mike Yearwood
- Fewer files to have around
Is this really a benefit? -- Mike Yearwood Yes. Only because VFP does not have something for classes like the .PRG, which can be a module unto itself without the need for additional physical containers. -- Mike Yearwood
SET CLASSLIB TO commands required
. This may be a significant point! -- Mike Yearwood
A neat trick, which the Visual FoxExpress framework uses is to build a table of all the VCX and PRG files in the project and put them into a .dbf that is included in the project. Then in your main run a function that automates the SET CLASSLIB and SET PROCEDURE calls. -- Bob Archer Hi Bob. That still requires running many SET CLASSLIB commands. I don't use any SET PROCEDURE calls, but I must use SET CLASSLIB calls, because I have no choice! -- Mike Yearwood
- Potentially easier to find classes
. Is this because there would be more classlibs to open? I think this is a documentation issue. In fact, you'd be looking through a long list of classes to find a particular one. -- Mike Yearwood The length of the list of classes is the same. It's the length of the list of class libraries that would potentially change.
- Grouping/packaging of classes that belong together. Hey, what are libraries for?
What defines what makes classes belong together? Do all base classes belong in one classlib? -- Mike Yearwood Some say form, others say function, others say module. It's something that should be agreed upon by a project team. In general, any type of logical grouping of components helps with organization. What's logical to one will not be logical to another. -- Mike Yearwood That's obviously not necessarily true, and in most cases false. A class library named Customer that contains customer forms and related components would make sense to pretty much any developer immediately. Too often I see a single classlib that contains completely unrelated things. In most cases the logical grouping does not exist. -- Mike Yearwood
- Only one developer at a time can work on any of the classes in a class library, helping to maintain and promote consistency throughout the library
If so, then how can any group of people work together? Surely the resulting inconsistency would make for something hideous? -- Mike Yearwood.
- Easier distribution of a society of classes. During runtime there is no distribution. The design of classes should be focused on use and reuse of the classes at runtime. If you have a class that has proper loose connections to other classes in other libraries, you will still have to find a way to distribute them. So just put all classes in one VCX and there you go all your distribution problems are gone. -- Mike Yearwood
- Easier identification of a society of classes.
- Easier to understand how another developer viewed class collaborations. The class collaborations at design time are unlikely matched by the physical arrangment in the classlibs. -- Mike Yearwood Really, so if someone had a class library named something like Explorer and it had in it a suclass of the treeview, listview and imagelist it wouldn't make sense to you? Now we're getting somewhere! I understand your confusion! I don't mean a single row in a VCX at all. Your explorer classlib can have subcomponents, classes that have been subclassed to support the explorer class are totally valid. That's just like having an SCX with a bunch of contained controls. However, the scx itself is the module! That's perfectly acceptable to me. It is not valid to create a new treeview that could be used outside of the explorer class and house it inside the explorer vcx. Because then I have no easy way to find that treeview. You can subclass the VFP treeview, add multi-application-wide functionality to it, store it in it's own classlib. Subclass that treeview and add Explorer-specific functionality and store it in the explorer classlib. The explorer-specific treeview is not a class anymore. It is not intended to be subclassed for anything else. You would intend to subclass the explorer. -- Mike Yearwood
- The class browser gets progressively slower - painfully slower - with very large vcxs. -- Mike Yearwood
- Only one developer at a time can work on any of the classes without source control - which is imperfect.
This is not a problem anymore. Now you can do concurrent programming with FoxPro binaries in 2 or more branches using Fox Bin 2 Prg, merge the changes and rebuild the binaries. -- Fernando DBozzo
- No chance of classes which contain other classes of being separated from it's 'children', if in the same classlib
I don't understand this :-( -- Kurt If a set of classes are components of a single class in the vcx, like the added components of an SCX are in the scx, then the contained classes don't get separated from the parent. -- Mike Yearwood
- The EXE build 'pulls in' all classes in the class library (VCX) even if you only use one of them in your program, potentially bloating the EXE.
- If the classlib gets corrupted, any changes since your last backup may have to be restored, damaging many classes at once.
- Source Control has to do much more work to integrate changes from multiple developers. At times, it will fail, requiring manual intervention. Who wants to do more work? -- Mike Yearwood
#NEW This is only true when source control is used improperly or circumvented. . Source control can be tricky to setup and can fail. Nothing is perfect.
- If a class in one multi-class classlib ends up being needed in another app, it will require refactoring to move this class to a new common classlib. -- Mike Yearwood - this is only true if there's demonstrable and significant harm from having the unused classes in the other project.
NONE of the arguments above are persuasive in the least for either case. Some are erroneous from my point of view.
There are instances in life, and in VFP, where one way of approaching something is equally "good" as another and in such cases personal preference will rule. -- Jim Nelson
We have only a defacto standard of putting many classes in a single (and I use the term lightly) library. If this is just personal preference to you, then ignore the matter. If not, then instead of writing the whole thing off show where there are mistakes.
Consider the following: VFP's own classes (not the FFC) are not stored in any class library. Why must our classes be stored in a library? When you try to subclass one of them VFP responds with "Class filename required." not "class library filename required." The structures of the scx and vcx seem to be identical. So why is the scx not referred to as a screen library?
It seems no one has really thought this through. All I know is there is no clear description of what classes should be grouped together. Frankly everything is personal preference. We can discover alternative ways but it's up to the individual to adopt them. What is important is to have open discussion on these ideas. I feel very frustrated when I come up with an idea and you and others squash it before you've even tried it. -- Mike Yearwood
Sorry, Mike, but I don't see where, in what I commented, I even came close to squashing it!
And you don't know that I've tried it or not, do you?
One thing I know about you, Mike, is that you're persistent. When you believe something you will go as many miles as needed to get your point through. And that's good.
At this point I still see only personal preference as the determinant. The pros/cons above are weak both ways by any technical measure I might use. -- Jim Nelson
It seems like a lot of the "cons" above can be mitigated by simple tools.
the mc() tool to allow you to edit a class without needing to know or specify the lib it is in.
the shareclass browser adding that allows you to copy a single class from one lib to another.
an automated tool to run your SET CLASSLIB calls. -- Bob Archer
Thanks Bob. I've been arguing that many of these addins were invented to work around problems caused by not layout out the classes more atomically instead of what seems to me to be total chaos. It would be good to use the Component Gallery regardless of the class-to-vcx ratio. Can you provide some link to Steven Black's mc utility? -- Mike Yearwood
See also Dup Class X, New Lib X, Add Info X -- vt
Category VFP Commands
Contributors: Peter Crabtree, Mike Yearwood
See Also: VFPSet Procedure PRGvs VCX
( Topic last updated: 2016.03.02 12:21:23 PM )