Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Feedback Please: .VCX vs .PRG
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00060795
Message ID:
00060938
Views:
32
>>>>My latest project involves 4 programmers, and we've opted to use PRGs for many items and a PROC file for a 'bunch' of small functions used repeatedly. We've found it's easier to keep the code up-to-date for all of us. Because of some system limitations, we have to send our code to one person who manages the Visual Source Safe, so checkouts are not totally reliable.
>>>
>>>I think the question was rather "classes in VCXs vs classes in PRGs" than "classes in VCX vs func/proc in PRGs".
>>>
>>>I totally agree that funcs/procs are still the easiest way to go for many small problems. I don't really see a good reason for defining classes in PRGs. Although, I heard that many programmers are doing this. So, I would like to hear some reasons for it.
>>>
>>>Vlad
>>
>>Vlad,
>>
>>One reason is that the memory required for PRGs is significantly less than VCXs. This is something that I had heard, but never tested until now. I created a simple class with one custom property and one custom method. Using SYS(1016), I measured how much memory was used by these objects. The PRG used approximately 11K less than the VCX. I test this twice, re-starting VFP each time with the same results.
>>
>>In general, I use both, depending strictly on what the class is designed to do and work with.
>>
>>George
>
>
>George:
>
>Have you found SYS(1016) to be reliable? After reading your post, I conducted a similar test.
>I found that SYS(1016) changes after every line of code - regardless of whether objects
>were created, variables were created, tables were opened... At startup, two consecutive ? SYS(1016)
>returned different values. Subsequent ? SYS(1016) match the second value until another line
>of code (RELEASE ALL, CLEAR ALL, HELP...) is issued in the command window. Then a new value is returned.
>
>I created a form without any controls in a .PRG and in a .VCX I found that the SYS(1016) was
>lower when SET CLASSLIB was issued than when SET PROC TO (by about 6K). However, when
>oForm.Show() was issued, SYS(1016) was 2K lower for the object created from a .PRG.
>
>Before each object was created, I restarted Fox - I didn't create them during the same session.
>I checked SYS(1016) after each line of code but am a little confused about its results.
>Any thoughts?
>
>Dan

Given what I did, I think that the conclusion is valid. Basically, each session was one of the following:

? SYS(1016)
* This was used in one session
SET PROCEDURE TO ClasTest.prg
* This in the other
SET CLASSLIB TO ClasTest.vcx
oTest = CREATEOBJECT("ClassTest")
oTest.ShowMemory()

Both had a custom property .cTextValue, which was initially set as an null string, and initialized in each object's Init method. The ShowMemory custom method was simply a WAIT WINDOW displaying the .cTextValue property + SYS(1016). Since I did the test 4 times, two for each, restarting VFP for each test, and that I got similar results each time, I would say that my conclusion regarding usage is valid.

SYS(1016) measures the amount of memory that user-defined objects take up. According to the VFP help file, "User-defined objects include: user-defined windows, menu bars, menus, variables, arrays, open tables, files opened with low-level file functions, and so on."
CLEAR ALL, RELEASE ALL etc. will impact these numbers because both release memory variables and arrays, with CLEAR ALL also releasing user defined menus, etc.

One of thing of note. The use of the ADDITIVE keyword, will impact the results. I've run some more tests, and have gotten as little as 2K difference, with the PRG still using less memory.

George
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform