>In response I have to say that I completely disagree.
Don't you want to change "completely" in "partially"? :)
>While there may not be a way to do exactly what I originally
>wanted, I think #DEFINE and #INCLUDE are excellent features!
They are good and very useful sometimes. I only wanted to say that its better to avoid them when possible and to not over use them. I don't want to generate a long discussion here, but #DEFINE is not recommended even in C/C++. I've read good articles both pro and con. I agree that it's better to avoid them when not needed.
>For starters, the compile time concern is baseless. My apps
>usually compile into APP's or EXE's in only a minute or so,
>and even if it took longer - who cares? Most client have no
>idea what 'Compiling' is and probable would'n't care anyway.
Obviously, the clients don't care because they don't see it. I care about the compile time because it cuts from my development time. And it's not only compile time. Every time you close a form/class that includes files, all the code is parsed for all #DEFINEs and this is very slow.
>Secondly, you would advicate using a public variable in an
>object oriented application?
Yes, if it's a good solution. It depends on the problem. (All rules can be broken when needed.) Being an array, I suggested a public var because object array properties cannot be passed as params to functions (major disadvantage IMHO).
>Third, what if my class was a stand alone custom class that
>needed to retrieve some static info? Would you instantiate
>an object just to get that info?
Why not?
Anyway, you can put your array in a prg and call that prg in the initialization part of your dll(s).
BTW, static means public, so... :)
>Take for example a custom class that I might want to create
>as a DLL. This DLL would not be part of any specific application
>and will need to know a number of subfolders names off a given
>directory. The subfolder names list is static.
Ok. The array in a prg solution works just fine.
>Why not put them into an include file, and include the file in
>the custom class? This would be an excellent example for defining
>an array in an include file.
Mainly because #DEFINE is not appropriate in this case. This directive defines names that are replaced by a specific text. That's all it can do. Or am I wrong?
The array in prg is exactly the same only that it doesn't use #DEFINEs and #INCLUDE.
>Since I might have any number of DLL's that use this same array of
>info, all I need to do is include the header file and I have access
>to the info I need. Much less work than creating an object I dont
>need, and in addition, you then wont have some unrelated object
>compiled into the DLL.
Just call the prg from the Init method. It's the same without the overhead of the #define replacements.
Vlad
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only