且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

你如何处理VB6中缺少构造函数?

更新时间:2023-11-13 16:13:28

我通常坚持工厂方法,构造函数用于相同模块中的相关类(.BAS扩展)。可悲的是,这远远不是最优的,因为你不能真正限制访问在VB6中的正常对象创建 - 你只需要提出一点,只有通过工厂创建你的对象。更糟糕的是,不得不在实际对象和你的工厂方法之间跳转,因为IDE中的组织本身是最麻烦的。

I usually stick to factory methods, where I put the "constructors" for related classes in the same module (.BAS extension). Sadly, this is far from optimal since you can't really limit access to the normal object creation in VB6 - you just have to make a point of only creating your objects through the factory. What makes it worse is having to jump between the actual object and your factory method, since organization in the IDE itself is cumbersome at best.