模块与类 [英] Module vs Class

查看:67
本文介绍了模块与类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我是VB.net的初学者,我不知道

模块与类之间有什么主要区别。


有人可以指导我何时使用模块或类的最佳情况。


我不知道何时应该使用模块或类,因为没有我使用

模块或类,我总能得到我想要的结果。但是

只是声明和调用方法有点不同。


问候


Hi,

I am a VB.net beginner, I do not know what are the major difference between
Module vs Class.

Could someone guide me when is the best situation to use Module or Class.

I have no idea when should I use module or class, because no matter i use
module or class, i always could get the results that are what i want. but
just the declare and calling method is a bit different.

Regards
Chong

推荐答案

你好,


这都是面向对象的问题。查找面向对象

编程在谷歌或类似的东西,或者可能给自己一本

深度的书,因为这里很难解释。这是值得你花时间的b $ b :-)


尼克。


" A_PK" < PK *** @ hotmail.com>在留言中写道

news:uR ************** @ TK2MSFTNGP10.phx.gbl ...
Hi there,

It''s all a matter of object orientation. Look up "Object Orientated
Programming" on google or something like that, or maybe get yourself an
in-depth book, because it is something rather hard to explain in here. It
would be worth your while :-)

Nick.

" A_PK" <pk***@hotmail.com> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...

我是VB.net初学者,我不知道模块与类之间有什么主要区别。

有人可以指导我何时使用最好的情况模块或类。

我不知道何时应该使用模块或类,因为无论我使用模块还是类,我总能得到我想要的结果。但
只是声明和调用方法有点不同。

Chong
Hi,

I am a VB.net beginner, I do not know what are the major difference
between Module vs Class.

Could someone guide me when is the best situation to use Module or Class.

I have no idea when should I use module or class, because no matter i use
module or class, i always could get the results that are what i want. but
just the declare and calling method is a bit different.

Regards
Chong



你好,

vb.net中的模块具有共享的所有内容。性质。一旦被宣布,它将在整个生命周期中出现,并在

申请开始时实现。这种方法引入了太多的全局变量,其中
并不好,随着程序的增长,你会有很多变数,这些变量属于整个程序和你有点扼杀

封装等概念。然而,使用类是一种理想的方法,你需要在baclarating之前考虑
,并且关联什么变量

属于哪个类并且出于何种目的。你应该避免使用

模块,我认为它们仅用于兼容旧版本的

VB。

希望有所帮助。 />
Abubakar。
http://joehacker.blogspot.com

" A_PK"写道:
Hello,
Module in vb.net has everything of a "shared" nature. Once delared it''ll be
there throughout the lifetime and instanciated at the start of the
application. This kindof approach introduces too many global variables, which
is not good and as the program grows you''ll have a lot of variabes which
belong to the whole program and you kind of kill the concept of
encapsulation, etc,. Use of classes is however an ideal approach where you
think before daclarating and have association-ship as to what variable
belongs to which class and is there for what purpose. You should avoid using
modules, i think they are there only for compatibility with older versions of
VB.
hope that helps.
Abubakar.
http://joehacker.blogspot.com
"A_PK" wrote:


我是VB.net的初学者,我不知道
Module vs Class之间的主要区别是什么。

有人可以指导我何时使用模块或类的最佳情况。

我不知道何时应该使用模块或类,因为无论我使用什么? />模块或类,我总能得到我想要的结果。但
只是声明和调用方法有点不同。

Chong
Hi,

I am a VB.net beginner, I do not know what are the major difference between
Module vs Class.

Could someone guide me when is the best situation to use Module or Class.

I have no idea when should I use module or class, because no matter i use
module or class, i always could get the results that are what i want. but
just the declare and calling method is a bit different.

Regards
Chong



您好Abubakar,


模块不适用于传统的兼容性。对于模块来说总是需要

,并且采用

的优势当然也不错。它们非常适合存储实用程序方法或全局

常量。有些人*喜欢*使用共享

成员的课程来达到同样的效果,但这既不在这里也不在那里。


他们完全适合2不同的目的,不应该比较这样的,blasses是面向对象的方法,模块

不是。


尼克。


" Abubakar" < AB- ****** @ discussions.microsoft.com>在消息中写道

news:92 ********************************** @ microsof t.com ...
Hi Abubakar,

Modules are not for legacy compatability. There will allways be the
need for modules, and it''s certainly not bad programming practice to take
advantage of them. They are great for storing utility methods or global
constants for example. Some people *like* to use classes with shared
members to achieve the same effect but this is neither here nor there.

They are fit for 2 completely different purposes and shouldn''t be
compared as such, Classes are for object orientated approaches, modules
aren''t.

Nick.

"Abubakar" <Ab******@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
你好,
vb.net中的模块具有共享的所有内容。性质。一旦被宣布,它将在整个生命周期中存在,并在
应用程序开始时实现。这种方法引入了太多的全局变量,
并不好,而且随着程序的增长,你会有很多变种属于整个程序并且你有点杀戮
封装等概念。然而,使用课程是一种理想的方法,你可以在开始之前思考,并且关于哪个变量属于哪个类并且出于什么目的而关联。你应该避免使用
模块,我认为它们仅用于与VB的旧版本兼容。
希望有所帮助。
Abubakar。
http://joehacker.blogspot.com

A_PK写道:
Hello,
Module in vb.net has everything of a "shared" nature. Once delared it''ll
be
there throughout the lifetime and instanciated at the start of the
application. This kindof approach introduces too many global variables,
which
is not good and as the program grows you''ll have a lot of variabes which
belong to the whole program and you kind of kill the concept of
encapsulation, etc,. Use of classes is however an ideal approach where you
think before daclarating and have association-ship as to what variable
belongs to which class and is there for what purpose. You should avoid
using
modules, i think they are there only for compatibility with older versions
of
VB.
hope that helps.
Abubakar.
http://joehacker.blogspot.com
"A_PK" wrote:


我是一个VB.net的初学者,我不知道
之间有什么主要的区别
模块与类。

有人可以指导我何时使用模块或类的最佳情况。

我不知道何时应该使用模块或类,因为无论如何我使用
模块或类,我总能得到我想要的结果。但
只是声明和调用方法有点不同。

Chong
Hi,

I am a VB.net beginner, I do not know what are the major difference
between
Module vs Class.

Could someone guide me when is the best situation to use Module or Class.

I have no idea when should I use module or class, because no matter i use
module or class, i always could get the results that are what i want. but
just the declare and calling method is a bit different.

Regards
Chong



这篇关于模块与类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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