A97应用程序中的许多全球变量 - 好还是坏?为什么? [英] Many global vars in an A97 app - good or bad? Why?

查看:43
本文介绍了A97应用程序中的许多全球变量 - 好还是坏?为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了一些帖子,表明在访问应用程序中拥有大量的GV'是一个糟糕的主意。就我个人而言,我喜欢GV和我一起使用它们(可能会滥用它们)一直用于所有的事情

可以想象 - 已经多年了。如果机器有内存,那么Windows可以使用它 - 我在想为什么不呢?


我想知道是什么你不得不说,

特别是任何严重的陷阱。你有不幸的

经验可以应对。

I''ve read some posts indicating that having tons of GV''s in
an Access app is a bad idea. Personally, I love GVs and I
use them (possibly abuse them) all the time for everything
imaginable - have been for years. If the machine has memory
to spare and windows can use it - I''m thinking "Why not?"

I was wondering what some of you have to say about that,
particularly any severe "gotchas" you''ve had the unfortunate
experience to contend with.

推荐答案

2005年11月8日星期二11:24 :15 -0500,MLH< CR ** @ NorthState.net>写道:
On Tue, 08 Nov 2005 11:24:15 -0500, MLH <CR**@NorthState.net> wrote:
我读过一些帖子,表明在Access应用程序中拥有大量的GV'是一个坏主意。就我个人而言,我喜欢GV并且我一直在使用它们(可能会滥用它们),这些都是可以想象的 - 已经存在多年了。如果机器有备用的内存和窗户可以使用它 - 我在想为什么不呢?

我想知道你们有些人对此有何评价,
特别是任何严重的陷阱。你有不幸的经历可以抗衡。
I''ve read some posts indicating that having tons of GV''s in
an Access app is a bad idea. Personally, I love GVs and I
use them (possibly abuse them) all the time for everything
imaginable - have been for years. If the machine has memory
to spare and windows can use it - I''m thinking "Why not?"

I was wondering what some of you have to say about that,
particularly any severe "gotchas" you''ve had the unfortunate
experience to contend with.




问题是全局变量将代码紧密地结合在一起
$ b不同时间$ b不同的东西,因为任何代码都可以随时更新

变量,你永远无法确定它是否处于您认为的状态

it是。一般来说,最好是你可以安排每一段代码

将数据直接发送到将要使用它的东西。


一个滥用我经常看到的globabl vairables是跟踪

最后一个活动控件。这样做的麻烦是,当你切换表格之间的焦点时会发生什么?这个变量的正确位置是'

模块的形式,对于我们正在谈论的'状态'没有混淆

about 。



The problem is that global variables tightly couple together code that does
different things at different times, and since any code can update the
variable at any time, you can never be sure it was left in the state you think
it was. Generally, it''s best if you can arrange for each piece of code to
send data directly to the thing that will use it.

One abuse of globabl vairables I''ve seen frequently is to keep track of the
last active control. The trouble with this is, what happens when you toggle
the focus between forms? The right place for this variable is in the form''s
module, where there is no confusion as to what form''s state we''re talking
about.


我在所有的VB6程序中使用GV。我采用纸质原理图并将它们以电子格式放入电子格式中,并使用CGM

智能图形将智能化。我创建了一个由GV持有的索引选择的历史列表

。我说如果你需要使用它们但不要滥用它们

如果你不需要。

I use GV in all my VB6 programs. I take paper schematics and put them
into electronic format and put intelligence into them using CGM
intelligence graphics. I create a history list of an index selection
that is held by GV. I say use them if you need to but don''t abuse them
if you dont have to.


怎么样这3个:GlobalString,MySQL和GlobalVariant。我使用它们

真的是为了方便而不是任何东西。任何时候我想要结束一堆




MySQL =" SELECT tblNCcounties.County,tblNCcities.CityName

FROM(tblNCcities LEFT JOIN tblNCcityCountyJunctionTable"

MySQL = MySQL&" ON tblNCcities.CityID =

tblNCcityCountyJunctionTable.CityID)LEFT JOIN tblNCcounties ON

MySQL = MySQL& " tblNCcityCountyJunctionTable.CountyID =

tblNCcounties.CountyID WHERE(((tblNCcities.CityName)"

MySQL = MySQL&" = GetMyString()))ORDER BY

tblNCcities.CityName;"


然后分配一个组合框,其行源或执行RunSQL命令,这个

全局变量比衬衫上的口袋更方便。我没有必要支付它的价格或者其他任何东西 - 当我需要时它就在那里,所以我只是使用它。

这是一种习惯。虽然我认为在分配

之后它的价值得到了保证,但我确实意识到在一些基于cron的事件中运行某个地方

else,它可能会被改变。我想这本身就足以让他们放弃这种做法。但肯定会有一个很难的习惯来打破
。任何更多的评论 - 任何人?
What about these 3: GlobalString, MySQL and GlobalVariant. I use them
really for convenience more than anything. Anytime I want to concat a
bunch of crap like

MySQL = "SELECT tblNCcounties.County, tblNCcities.CityName
FROM (tblNCcities LEFT JOIN tblNCcityCountyJunctionTable "
MySQL = MySQL & "ON tblNCcities.CityID =
tblNCcityCountyJunctionTable.CityID) LEFT JOIN tblNCcounties ON "
MySQL = MySQL & "tblNCcityCountyJunctionTable.CountyID =
tblNCcounties.CountyID WHERE (((tblNCcities.CityName) "
MySQL = MySQL & "= GetMyString())) ORDER BY
tblNCcities.CityName;"

then assign a combo box its rowsource or do a RunSQL command, this
global var is a handier than a pocket on a shirt. I don''t have to
dimension it or anything - its there when I need it, so I just use it.
Its a habit. Even though I think its value is assured after assigning
it, I do realize that in some cron-based event running somewhere
else, it might possibly be changed. I guess that, in itself, is reason
enough to abandon the practice. But it sure will be a hard habit to
break. Any more comments - anybody?
问题是全局变量紧密地将代码组合在一起,在不同时间执行不同的事情,并且因为任何代码都可以更新
随时变量,你永远无法确定它是否处于你认为的状态。一般来说,最好是你可以安排每一段代码来直接将数据发送到使用它的东西。

我见过一次滥用globabl vairables经常是跟踪最后一次主动控制。这样做的问题是,当您切换表单之间的焦点时会发生什么?这个变量的正确位置是'
模块的形式,对于我们正在谈论的'状态'是什么形式没有混淆。
The problem is that global variables tightly couple together code that does
different things at different times, and since any code can update the
variable at any time, you can never be sure it was left in the state you think
it was. Generally, it''s best if you can arrange for each piece of code to
send data directly to the thing that will use it.

One abuse of globabl vairables I''ve seen frequently is to keep track of the
last active control. The trouble with this is, what happens when you toggle
the focus between forms? The right place for this variable is in the form''s
module, where there is no confusion as to what form''s state we''re talking
about.





这篇关于A97应用程序中的许多全球变量 - 好还是坏?为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆