English 中文(简体)
方案结构是否仍然经常使用单元?
原标题:Are Modules still commonly used in program structures?

我不是任何手段的方案设计者,但我真的希望开始更好地了解如何做到这一点,更好地了解情况。 互联网一般语言(VB,C#)。 我读了Wrox的一本书——2008年专业视觉基础。 在我看来,它提到单元正在慢慢地消失。 我可以理解,为什么大多数编码会进入一个类别物体,但我将假定模块至少对代码进行清理是必要的。

没有人能为我澄清这一点? 此外,我一直在寻找软件设计的良好来源,但我看不到最近出版的书籍。 我可能会在错误的地方进行搜查,但我真的要把手拿到。

谢谢。

最佳回答

总的来说,它们并不适合《禁止杀伤人员地雷公约》,但它们仍然使用,在某些情况下需要使用。

在VB。 净额,如果你想书写推广方法,你将不得不使用模块——汇编者只允许在其中界定推广方法。

当然,你可以不使用单元——一个具有私人建筑人的不可继承的类别,除了共同方法之外,其他方法将取得与单元相同的成果。

如同方案规划(和许多其他事项)中的所有内容一样,它们也有其用途,只要它们没有被滥用,就不存在问题。 工作的适当工具!

问题回答

模块关键词载于VB。 该网络主要与VB6和以前兼容。 之后,大多数VB代码是程序性的,具有独立的非等级子和职能。 这些语言在VB4周围的某个地方获得了“级关键词”。 从OOP的意义上来说,这不是真正的课程,而是没有支持继承。 根本的COM架构缺少一个特征。

它与《刑法》规定的执行模式完全一致。 没有支持自由职能,每一种方法都必须是某一类成员。 The VB. 该网络的汇编者通过宣布一个班子来复制模块,单元程序成为该组的共同方法。 你们可以通过Ildasm.exe看到这一点:

.class private auto ansi sealed ConsoleApplication1.Module1
       extends [mscorlib]System.Object
{
  .custom instance void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute::.ctor() = ( 01 00 00 00 ) 
} // end of class ConsoleApplication1.Module1

说明它如何是私的,以便守则能够提及并密封,从而使任何法典都无法从模块中得出一个等级。

C#汇编者与“法定类别”完全相同,CLR没有固定类别的概念。 静态班级有很充分的理由,“分子”的想法已经过时。 你们也可以通过在VB宣布一个不可容忍的班级来做到这一点。 NET代码,只有共同方法。 The VB. 然而,网络汇编者并没有强制实施像C#汇编者那样的共同方法,也没有允许你宣布这一类为私人。 因此,模块只是罚款。

模块是VB最接近的固定班级,即便是在面向目标的环境中进行方案规划,这种班级也非常有用。

由于VB没有固定的班级,模块就象我所知,是创造推广方法的唯一途径。

您需要模块,以界定自己的 延伸方法





相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签