Showing posts with label Object Oriented. Show all posts
Showing posts with label Object Oriented. Show all posts

Monday, October 16, 2006

VB.NET v.s. C# v.s. Java

^ 有人说有经验的programmer在VB.NET和C#之间转换只需要一个星期的时间,我也觉得不需要费多久。我现在在一个咨询项目里使用这两种语言,经常是今天VB.NET,明天C#,需要做的就是偶尔查查MSDN上的Language Syntax Reference。写程序,关键的是编程思想,语法差别不是重要的。所以,我很乐意地说:VB.NET和C#我都用得挺好。
^ 我从前写了四五年Java,从Java到C#转换我没有感觉有多少困难。反正我写程序的方式、风格、思路还是一样。并且,我还是可以随时用Java编程。所以,我认为:
最重要的是deep understanding of Object-Oriented。
非常重要的是programming patterns and best practices。
很重要的是very familiar with class library
也很重要的是experienced with top IDEs。

e How popular is VB .NET versus C#?
e VB.NET and C# Comparison
e Java (J2SE 5.0) and C# Comparison
e VB.NET vs C#: The Great .NET Language Debate

What is Property, on earth?

@ Properties can be considered smarter fields in that they can be assigned to or read from (like a field), yet when this happens some code in the class executes, and therefore the author of the class can process the value being assigned or returned.

@ Inside the Property block, you write a Get…End Get block, which defines which value the property returns, and a Set…End Set block, which defines how values are assigned to the property.

@ In most cases, a property simply maps to a Private field, so the code for these two blocks often looks like this:

Dim m_BirthDate As Date
Public Property BirthDate() As Date
Get
Return m_BirthDate
End Get
Set(ByVal value As Date)
m_BirthDate = value
End Set
End Property

Tuesday, October 10, 2006

About VB.NET Procedure / Method

@ A procedure is a block of Visual Basic statements enclosed by a declaration statement (Function, Sub, Operator, Get, Set) and a matching End declaration. All executable statements in Visual Basic must be within some procedure.

@ Types of Procedures
Visual Basic uses several types of procedures:
· Sub Procedures perform actions but do not return a value to the calling code.
· Event-handling procedures are Sub procedures that execute in response to an event raised by user action or by an occurrence in a program.
· Function Procedures return a value to the calling code. They can perform other actions before returning.
· Property Procedures return and assign values of properties on objects or modules.
· Operator Procedures define the behavior of a standard operator when one or both of the operands is a newly-defined class or structure.
· Generic Procedures in Visual Basic define one or more type parameters in addition to their normal parameters, so the calling code can pass specific data types each time it makes a call.

Saturday, October 07, 2006

The constructor method of VB.NET

A constructor is a method that runs when a new instance of the class is created.
In Visual Basic, the constructor method is always named Sub New:


Class Person
Private CreateTime As Date
Sub New()
' Display a diagnostic message.
Console.WriteLine("A new instance of Person is being created.")
' Remember when this instance was created.
CreateTime = Now
' Perform other initialization chores.

End Sub
End Class