可用的OOP概念列表 [英] List of Available OOP Concepts

查看:76
本文介绍了可用的OOP概念列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VBA中为OOP(面向对象编程)构建一些材料. 有人可以列出VBA中可用的OOP概念吗?

I am building some material for OOP (object oriented programming) in VBA. Can anybody list me the OOP concepts which are available in VBA?

例如,通过阅读,我发现:

For example, from my reading I discovered that:

  1. 继承在VBA中不可用.
  2. 存在封装概念,因为您可以使用访问修饰符"private"并构建公共属性.

推荐答案

以下是我在VBA中使用OOP概念时所做的一些观察:

Here are some observations I've made while working with OOP concepts in VBA:

  • 您不能在VBA中重载方法.但是,无论您的好坏,都可以随意使用可选参数.
  • 您有一个无参数的Class_Initialize方法,该方法在实例化对象时被调用,但不能重载以处理参数.如果要在没有设置某些属性的情况下强制类不能完全正常运行",则必须编写自己的方法.
  • VB6和VBA编辑环境迫使您构建类文件",并将每个类保存在单独的文件中,这与模块不同.
  • 类和模块都可以具有公共字段和私有字段.模块中的公共字段本质上是全局变量.
  • 模块在功能上类似于C#中的静态类.可以从应用程序中任何位置的模块调用公共代码.
  • You cannot overload methods in VBA. However, you do have optional parameters at your disposable, for better or for worse.
  • You have one parameterless Class_Initialize method that is called when the object is instantiated, but it cannot be overloaded to handle parameters. If you want to force your class to not be "fully functional" without having certain properties set, you'll have to write your own way to do so.
  • The VB6 and VBA editing environment forces you to build "class files" and keep each class in a separate file, which are distinct from modules.
  • Classes and Modules can both have public and private fields. A public field in a module is essentially a global variable.
  • Modules are functionally similar to static classes in C#. Public code can be called from the modules anywhere within your application.

VB6/VBA范例将类设想为一种封装对象的功能和属性的方法.从这个意义上说,VB6/VBA的对象与任何其他基本OOP环境一样存在,并且应该在适当的地方鼓励它们的使用和设计.

The VB6/VBA paradigm envisions classes as a way to encapsulate an object's functionality and properties. In this sense, VB6/VBA's objects exist just like any other basic OOP environment and their use and design should be encouraged where appropriate.

但是,缺少一些关键的OOP功能会导致VB6/VBA无法完全实现完整的OOP设计模式.

However, the lack of several key OOP features cause VB6/VBA to fall short in being able to thoroughly implement a complete OOP design pattern.

这篇关于可用的OOP概念列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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