简体   繁体   English

你使用数据感知类吗?

[英]Do you use Data-aware classes?

I'm using VB6. 我正在使用VB6。

Data-aware classes refers to classes whose DataBindingBehavior or DataSourceBehavior property is set. 数据感知类指的是设置了DataBindingBehavior或DataSourceBehavior属性的类。

I learned this concept from MSDN and am wondering usually when should we use this technique of Data-aware classes? 我从MSDN学到了这个概念,我想知道我们何时应该使用这种数据感知类技术? Or just like the Data Environment Designer which is just ignored by most developers? 或者就像大多数开发人员忽略的数据环境设计师一样?

The ability to create data-aware classes is just another aspect of Visual Basic's extensibility model. 创建数据感知类的能力只是Visual Basic可扩展性模型的另一个方面。 Along with the ability to create standard Classes and UserControls, you can create them as data-aware classes that can plug into VB's data binding mechanism. 除了能够创建标准类和UserControl之外,您还可以将它们创建为可以插入VB数据绑定机制的数据感知类。

You can wrap something like an ADO Recordset or ADO Data Control to create a more application-specific component, or you can create your own from scratch to provide data binding for some sort of out of the ordinary data. 您可以包装类似ADO Recordset或ADO Data Control的内容来创建更多特定于应用程序的组件,或者您可以从头开始创建自己的组件,以便为某种非常规数据提供数据绑定。 You can even create basic custom OLE DB Providers for unusual requirements by writing VB6 data aware classes in conjunction with the OLE DB Simple Provider (OSP) Toolkit. 您甚至可以通过将VB6数据感知类与OLE DB简单提供程序(OSP)工具包结合使用来创建基本的自定义OLE DB提供程序以满足不寻常的需求。

Most of these things are rarely used today, because VB6 education is sorely lacking. 今天很少使用这些东西,因为VB6教育非常缺乏。 A lot of programmers who learned by example shy away from data binding because they've found it frustrating. 许多通过实例学习的程序员回避数据绑定,因为他们发现它令人沮丧。 Most of this is a lack of understanding though. 其中大部分是缺乏理解。 Instead we fall back on writing a lot of QBasic-like procedural code that sacrifices the power of VB6 event based programming. 相反,我们回过头来编写许多类似QBasic的过程代码,这些代码牺牲了基于VB6事件的编程的强大功能。

You'll see the same thing in a lot of VB.Net and C# code loose in the wild. 你会在很多VB.Net和C#代码中看到相同的东西。 People seem unaware that event driven programming is actually much more important than the degree of "OOPiness" yet that's where the focus seems to be. 人们似乎并不知道事件驱动的编程实际上比“OOPiness”的程度更重要,但这似乎是焦点所在。

Programmers who understand the importance of this tend to have a lot fewer DoEvents loops in their VB6 programs and almost no gratuitous multithreading in their .Net programs. 了解其重要性的程序员往往在他们的VB6程序中有更少的DoEvents循环,而在他们的.Net程序中几乎没有任何无偿的多线程。

I am as guilty as anyone of avoiding the Data Environment Designer and bound controls. 我和任何避免使用数据环境设计器和绑定控件的人一样内疚。 I plan to become more aware of their use and capabilities though as well as making more use of VB6's Data Report Designer. 我计划更多地了解它们的用途和功能,同时更多地使用VB6的数据报表设计器。 These are powerful tools for writing data-centric programs, something I'm doing a lot more of lately. 这些是编写以数据为中心的程序的强大工具,我最近正在做更多的事情。


There is no argument that Microsoft has dropped all support for VB6 development. 毫无疑问,微软已经放弃了对VB6开发的所有支持。 But this doesn't say anything about the demand for it, which continues to be strong. 但这并没有说明对它的需求,它仍然很强劲。 If people have little to contribute to answering a question about VB6 they might spend their effort better elsewhere instead of shouting it down here. 如果人们对回答有关VB6的问题没什么贡献,他们可能会在其他地方更好地付出努力,而不是在这里大喊大叫。 It is very sad that we never got a follow-on product - a newer VB supporting 64-bit development would be really nice. 令人遗憾的是,我们从未获得过后续产品 - 支持64位开发的新VB非常好。 It just isn't in the cards. 它只是不在卡片中。

Do you have any idea how old VB6 is? 你知道VB6多大了吗? It's about ten years old. 它已经十年了。 You should pretty well ignore anything you "learn" from VB6. 你应该很好地忽略你从VB6“学习”的任何东西。


Some resources on VB6: VB6上的一些资源:

All of this is from the following search: http://social.msdn.microsoft.com/Search/en-US/?Refinement=22&Query=vb6 . 所有这些都来自以下搜索: http//social.msdn.microsoft.com/Search/en-US/ ?Refinement = 22&Query = vb6

I think that feature has been ignored by most VB6 developers. 我认为大多数VB6开发人员都忽略了这个功能。 Certainly I experimented with it once and never used it again. 当然,我曾经尝试过一次,再也没用过它。 If you Google DataBindingBehavior or DataSourceBehavior there are relatively few hits. 如果您使用Google DataBindingBehavior或DataSourceBehavior,则点击次数相对较少。

I think what John is trying to communicate in his answer is that VB6 is not a good choice for new development unless you have strong reasons to the contrary - for example if your organisation already has a lot of VB6 experience and a lot of VB6 code to maintain, and no experience of other desktop programming languages. 我认为John在他的回答中试图传达的是VB6不是新开发的好选择,除非你有充分的理由相反 - 例如,如果你的组织已经有很多VB6经验和很多VB6代码维护,没有其他桌面编程语言的经验。 That sounds unlikely in your case, otherwise you'd be asking your colleagues the question rather than posting on Stack Overflow! 在你的情况下听起来不太可能,否则你会问你的同事问题而不是在Stack Overflow上发帖!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM