jamie_pattison
Well-known member
- Joined
- Sep 9, 2008
- Messages
- 116
- Programming Experience
- Beginner
I have a project that im maintaining. I have come across the following class
Questions are:
1. Is this the 'standard' or preferred way of creating a class or is it a slightly modern/outdated technique?
2. Why have this line and what does it do?
3. FirstName is declared as a public variable. Wouldnt it have been better to have this as a property i.e. (
?
4. Is the Required attribute needed in the class? Many times developers would go to the page itself and write something similar to:
Thanks
VB.NET:
<MetadataType(GetType(Customer.CustomerMeta))> _
Partial Public Class Customer
Friend Class CustomerMeta
<Required(), StringLength(20)> Public FirstName As String
End Class
Questions are:
1. Is this the 'standard' or preferred way of creating a class or is it a slightly modern/outdated technique?
2. Why have this line and what does it do?
VB.NET:
<MetadataType(GetType(Customer.CustomerMeta))>
3. FirstName is declared as a public variable. Wouldnt it have been better to have this as a property i.e. (
VB.NET:
<Required(), StringLength(20)> Public Property FirstName As String)
4. Is the Required attribute needed in the class? Many times developers would go to the page itself and write something similar to:
VB.NET:
If myCustomer.FirstName.Length < 0 then msgbox "Please enter a customer name"
Thanks