I found an excellent tutorial on XML Serialization: http://addressof.com/blog/articles/E...alization.aspx
When he creates a class property, it looks like this:
Public Class Drivers
Private _wave As String
Public Property Wave() As String
Get
Return _wave
End Get
Set(ByVal Value As String)
_wave = Value
End Set
End Property
End Class
My question is, it seems to work equally well when done this way:
Public Class Drivers
Public Wave As String
End Class
Is there a reason to use the Property method?
Matthew 10 1195
Properties are basically Getter/Setter methods. In the designer, they will
appear in the property page of a component too. It is always better to hide
your implementation ( _wave) in theory behind a property like this. Your
class may have other depencies on _wave. For example, you may have a
"_subwave" item, which contains a subset of _wave. Obviously, when the user
sets a new _wave, the _subwave is still referencing the old _wave. In this
case, your property "set" method would be able to release the reference.
Thats just one example. They are flexible and don't add much overhead in
their most basic form.
"Matthew" <tu*************@alltel.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... I found an excellent tutorial on XML Serialization: http://addressof.com/blog/articles/E...alization.aspx
When he creates a class property, it looks like this: Public Class Drivers Private _wave As String Public Property Wave() As String Get Return _wave End Get Set(ByVal Value As String) _wave = Value End Set End Property End Class
My question is, it seems to work equally well when done this way: Public Class Drivers Public Wave As String End Class
Is there a reason to use the Property method?
Matthew
AND . . .
In addition, it allows you to process the input or to validate it before it
sets the internal variable
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:ck*******************@news.demon.co.uk... Properties are basically Getter/Setter methods. In the designer, they will appear in the property page of a component too. It is always better to hide your implementation ( _wave) in theory behind a property like this. Your class may have other depencies on _wave. For example, you may have a "_subwave" item, which contains a subset of _wave. Obviously, when the user sets a new _wave, the _subwave is still referencing the old _wave. In this case, your property "set" method would be able to release the reference. Thats just one example. They are flexible and don't add much overhead in their most basic form. "Matthew" <tu*************@alltel.net> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...I found an excellent tutorial on XML Serialization: http://addressof.com/blog/articles/E...alization.aspx
When he creates a class property, it looks like this: Public Class Drivers Private _wave As String Public Property Wave() As String Get Return _wave End Get Set(ByVal Value As String) _wave = Value End Set End Property End Class
My question is, it seems to work equally well when done this way: Public Class Drivers Public Wave As String End Class
Is there a reason to use the Property method?
Matthew
AND . . .
In VS2005, you are able to set access modifiers for get/set ( Mutually
Exclusively ) below the level and independently of the properties access
modifer. So for example, the property get could be set to public and the set
to freind etc.
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:eG****************@TK2MSFTNGP10.phx.gbl... AND . . .
In addition, it allows you to process the input or to validate it before it sets the internal variable
-- OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray() For i As Int32 = 0 To ch.Length - 1 ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1) Next Process.Start("mailto:" & New String(ch)) --
"Robin Tucker" <id*************************@reallyidont.com> wrote in message news:ck*******************@news.demon.co.uk... Properties are basically Getter/Setter methods. In the designer, they will appear in the property page of a component too. It is always better to hide your implementation ( _wave) in theory behind a property like this. Your class may have other depencies on _wave. For example, you may have a "_subwave" item, which contains a subset of _wave. Obviously, when the user sets a new _wave, the _subwave is still referencing the old _wave. In this case, your property "set" method would be able to release the reference. Thats just one example. They are flexible and don't add much overhead in their most basic form. "Matthew" <tu*************@alltel.net> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...I found an excellent tutorial on XML Serialization: http://addressof.com/blog/articles/E...alization.aspx
When he creates a class property, it looks like this: Public Class Drivers Private _wave As String Public Property Wave() As String Get Return _wave End Get Set(ByVal Value As String) _wave = Value End Set End Property End Class
My question is, it seems to work equally well when done this way: Public Class Drivers Public Wave As String End Class
Is there a reason to use the Property method?
Matthew
Matthew, Is there a reason to use the Property method?
The property Encapsulates the wave field. Some features, such as the
PropertyGrid requires them.
Remember that Encapsulation is one of the tenets of Object Oriented
Programming.
Here are a couple of blogs that make a good case against using Properties: http://weblogs.asp.net/jaybaz_ms/arc...29/123333.aspx http://weblogs.asp.net/ericgu/archiv...29/123588.aspx
Hope this helps
Jay
"Matthew" <tu*************@alltel.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...I found an excellent tutorial on XML Serialization: http://addressof.com/blog/articles/E...alization.aspx
When he creates a class property, it looks like this: Public Class Drivers Private _wave As String Public Property Wave() As String Get Return _wave End Get Set(ByVal Value As String) _wave = Value End Set End Property End Class
My question is, it seems to work equally well when done this way: Public Class Drivers Public Wave As String End Class
Is there a reason to use the Property method?
Matthew
>In the designer, they will appear in the property page of a component too.
The designer? Does this mean there is a faster way to set this up than
typing the whole thing out?
Matthew
>In the designer, they will appear in the property page of a component too.
The designer? Does this mean there is a faster way to set this up than
typing the whole thing out?
Matthew
"Matthew" <tu*************@alltel.net> wrote in news:#gb3Az6qEHA.3728
@TK2MSFTNGP09.phx.gbl: My question is, it seems to work equally well when done this way: Public Class Drivers Public Wave As String End Class
Is there a reason to use the Property method?
Typically you don't want direct access to your variables.
With properties you have the ability to do some validation or checks.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying. http://members.ebay.com/aboutme/coolspot18/
Matthew,
I am always thinking should it be done because is told that it has to be
done, or should it be done because it has sense. I think that OHM did give
some very good answers on that when it should be done which I completly
agree.
The same for Robin who told when you make components (what he not wrote
however I think he did mean or your own reusable controls or forms) than it
makes in my opinion forever sense. Because than you can use the designer and
the property grid.
However I am as well in doubt why would you use properties for a one time
dialogform, which is never more reused.
Just my thought, and maybe we get some comments that helps us both even more
than with the text from OHM, from Robin.
While Jay keeps himself for me in this (what I always see as one of his
specialitys in this newsgroup) in the same situation as me, however maybe I
am wrong, and than I am sure Jay will tell that. (When I misunderstand your
message, than it was completly my fault in this Jay)
:-)
Cor
Cor, However I am as well in doubt why would you use properties for a one time dialogform, which is never more reused.
Which is the point of the two blog links I gave.
For a Dialog my properties normally delegate to properties on contained
controls instead of fields, where the contained controls are all private, in
which case Properties make sense, as I don't want to expose the fact that a
TextBox is used for the first name, just that there is a first name
available... Also the properties allow me to validate input when I set it.
Something like:
Public Class PersonDialog
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
....
Private WithEvents txtFirstName As System.Windows.Forms.TextBox
Private WithEvents txtLastName As System.Windows.Forms.TextBox
....
#End Region
Public Property FirstName() As String
Get
Return txtFirstName.Text
End Get
Set(ByVal value As String)
If value Is Nothing Then Throw New
ArgumentNullException("FirstName")
txtFirstName.Text = value
End Set
End Property
Public Property LastName() As String
Get
Return txtLastName.Text
End Get
Set(ByVal value As String)
If value Is Nothing Then Throw New
ArgumentNullException("LastName")
txtLastName.Text = value
End Set
End Property
End Class
Dim dialog As New PersonDialog
dialog.FirstName = "Jay"
dialog.LastName = "Harlow"
dialog.ShowDialog()
Hope this helps
Jay
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uO****************@TK2MSFTNGP12.phx.gbl... Matthew,
I am always thinking should it be done because is told that it has to be done, or should it be done because it has sense. I think that OHM did give some very good answers on that when it should be done which I completly agree.
The same for Robin who told when you make components (what he not wrote however I think he did mean or your own reusable controls or forms) than it makes in my opinion forever sense. Because than you can use the designer and the property grid.
However I am as well in doubt why would you use properties for a one time dialogform, which is never more reused.
Just my thought, and maybe we get some comments that helps us both even more than with the text from OHM, from Robin.
While Jay keeps himself for me in this (what I always see as one of his specialitys in this newsgroup) in the same situation as me, however maybe I am wrong, and than I am sure Jay will tell that. (When I misunderstand your message, than it was completly my fault in this Jay)
:-)
Cor
Jay,
That it can be done in the way you do it, is for me no question, however I
asking myself more and more what is the "benefit" of using properties in the
case of a dialogboxclass beside that you can say: communication between
classes "has" to be done with properties.
I do not see the benefits in these situations (When it is not a reused
dialogbox but just a simple one just needed for a special situation)
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Krasimir_Slaveykov |
last post by:
Hello ,
I have a problem with constructing correct SQL.
I have tables:
TABLE1 wich have FIELD1 and FIELD2
TABLE2 wich have FIELD1 and FIELD2
TABLE3 wich have FIELD1, FIELD2 and FIELD3
I...
|
by: Last Timer |
last post by:
class A {
public:
A(int a, int b) { this.a=a; this.b=b};
int a;
int b;
}
class B : x(3), y(3), public A(1,3)
{
|
by: karthick |
last post by:
Hi,
I am constructing a Message (Body) for sending our Emails. It is around
3000 characters long. But for whatever reason, the last line seems to
be broken with a "!" exclamatory mark in it,...
|
by: cainlevy |
last post by:
Hey all,
What are the pros and cons of defining methods in the constructor vs
through the prototype? For example:
Constructing:
-------------
function MyObj()
{
this.MyMethod = function()...
|
by: Michael Schuerig |
last post by:
In my experience most available books and web publication on CSS are
related to web page/site design. Little attention is payed to the
design and construction of web-based application for data...
|
by: grocery_stocker |
last post by:
Why would someone go through the trouble of constructing an error
handling function using variable-length argument lists? Why not just
use something like printf()?
|
by: jesper |
last post by:
Hi.
This might be to basic, or of topic, or just plain silly. But, Is there
a nice way to
construct objects dynamically from a data stream (file, socket, memory)
without
prior enumerating...
|
by: Big George |
last post by:
Hello,
I develop in ASP.NET with VB.NET code.
I need some help constructing a class: Worker. I'm designing the
properties of this class.
The class is filled reading tables in database.
...
|
by: K Viltersten |
last post by:
I have a class that reads an XML and
according to its contents, it creates a
List<Letter>, where Letter is an abstract
class that is implemented in Alpha and
Beta classes.
I use a foreach...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |