By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,199 Members | 1,721 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,199 IT Pros & Developers. It's quick & easy.

structs ...

P: n/a
Hi,

I am using structs and am also using property accessors to access those
private member fields... TO me this is a good way of handling them, but I
find alot of people using direct access to the struct memebers, since
structs is just a type similar to a class (with differences I know) why
should I allow direct access like that... I looked at the Size and other
parts on Control etc and I find its the same way by using property
accessors.

Seems to me people think struct = direct access, small, and easy.. Its just
a type like all the rest (except with differences i Know blah blah) but why
why why allow direct access. its just lazyness.. Code it once, and thats it,
where is the saving? I mean if its coded well in the first place then you
dont have to keep engineering it so its not exactly a lot of work to use
those extra lines..

I also find ppl balk at the concept of using parameterized constructors and
methods in a struct, theyre just not thinking .NET , and are thinking the
old way of structs on C. The object is still lightweight even tho there are
methods, properties, and constructors..

I just hate lazy coding.

/End gripe.

Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"news.microsoft.com" <di********@discussion.microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,

I am using structs and am also using property accessors to access those
private member fields... TO me this is a good way of handling them, but I
find alot of people using direct access to the struct memebers, since
structs is just a type similar to a class (with differences I know) why
should I allow direct access like that... I looked at the Size and other
parts on Control etc and I find its the same way by using property
accessors.

It really depends on what your doing, when doing quick, dirty interop code,
writing property accessors is usually not important, and is infact a real
waste. However, exposing properties is often the best choice (in some cases
the only choice) to provide a simpler interface for structs that may be
accessed externally. However there is no hard and fast rule that I follow.
Seems to me people think struct = direct access, small, and easy.. Its just a type like all the rest (except with differences i Know blah blah) but why why why allow direct access. its just lazyness.. Code it once, and thats it, where is the saving? I mean if its coded well in the first place then you
dont have to keep engineering it so its not exactly a lot of work to use
those extra lines..

I also find ppl balk at the concept of using parameterized constructors and methods in a struct, theyre just not thinking .NET , and are thinking the
old way of structs on C. The object is still lightweight even tho there are methods, properties, and constructors..
I use methods, properties, and constructors where appropriate. I don't break
my back to add property accessors on structs sometimes, if it will just be a
get\set combo wrapped around a field. I would much prefer to see a method on
a struct than a static method that takes a parameter on that struct if at
all possible. I just hate lazy coding.
Don't we all, ;). /End gripe.

Jul 21 '05 #2

P: n/a
No i agree for quicn n dirty stuff but I mean for things that are going to
be used outside like components and user controls..

I seen people write formatting methods when its more sensible to override
ToString in the object and I just think they dont fully understand the
concept of an object. Theyre thinking straight C.

"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message
news:Kk5pb.83729$Fm2.63853@attbi_s04...

"news.microsoft.com" <di********@discussion.microsoft.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
Hi,

I am using structs and am also using property accessors to access those private member fields... TO me this is a good way of handling them, but I find alot of people using direct access to the struct memebers, since
structs is just a type similar to a class (with differences I know) why
should I allow direct access like that... I looked at the Size and other
parts on Control etc and I find its the same way by using property
accessors.

It really depends on what your doing, when doing quick, dirty interop

code, writing property accessors is usually not important, and is infact a real
waste. However, exposing properties is often the best choice (in some cases the only choice) to provide a simpler interface for structs that may be
accessed externally. However there is no hard and fast rule that I follow.
Seems to me people think struct = direct access, small, and easy.. Its just
a type like all the rest (except with differences i Know blah blah) but

why
why why allow direct access. its just lazyness.. Code it once, and thats

it,
where is the saving? I mean if its coded well in the first place then you dont have to keep engineering it so its not exactly a lot of work to use
those extra lines..

I also find ppl balk at the concept of using parameterized constructors

and
methods in a struct, theyre just not thinking .NET , and are thinking the old way of structs on C. The object is still lightweight even tho there

are
methods, properties, and constructors..

I use methods, properties, and constructors where appropriate. I don't

break my back to add property accessors on structs sometimes, if it will just be a get\set combo wrapped around a field. I would much prefer to see a method on a struct than a static method that takes a parameter on that struct if at
all possible.
I just hate lazy coding.

Don't we all, ;).
/End gripe.


Jul 21 '05 #3

P: n/a

"news.microsoft.com" <di********@discussion.microsoft.com> wrote in message
news:e3****************@tk2msftngp13.phx.gbl...
No i agree for quicn n dirty stuff but I mean for things that are going to
be used outside like components and user controls..

I seen people write formatting methods when its more sensible to override
ToString in the object and I just think they dont fully understand the
concept of an object. Theyre thinking straight C.
Very probably.

"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message
news:Kk5pb.83729$Fm2.63853@attbi_s04...

"news.microsoft.com" <di********@discussion.microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,

I am using structs and am also using property accessors to access those private member fields... TO me this is a good way of handling them, but I
find alot of people using direct access to the struct memebers, since
structs is just a type similar to a class (with differences I know)
why should I allow direct access like that... I looked at the Size and other parts on Control etc and I find its the same way by using property
accessors.

It really depends on what your doing, when doing quick, dirty interop

code,
writing property accessors is usually not important, and is infact a real waste. However, exposing properties is often the best choice (in some

cases
the only choice) to provide a simpler interface for structs that may be
accessed externally. However there is no hard and fast rule that I follow.
Seems to me people think struct = direct access, small, and easy.. Its
just
a type like all the rest (except with differences i Know blah blah)
but why
why why allow direct access. its just lazyness.. Code it once, and
thats it,
where is the saving? I mean if its coded well in the first place then you dont have to keep engineering it so its not exactly a lot of work to
use those extra lines..

I also find ppl balk at the concept of using parameterized

constructors and
methods in a struct, theyre just not thinking .NET , and are thinking the old way of structs on C. The object is still lightweight even tho

there are
methods, properties, and constructors..

I use methods, properties, and constructors where appropriate. I don't

break
my back to add property accessors on structs sometimes, if it will just be a
get\set combo wrapped around a field. I would much prefer to see a
method on
a struct than a static method that takes a parameter on that struct if

at all possible.
I just hate lazy coding.

Don't we all, ;).
/End gripe.



Jul 21 '05 #4

P: n/a

"news.microsoft.com" <di********@discussion.microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,

I am using structs and am also using property accessors to access those
private member fields... TO me this is a good way of handling them, but I
find alot of people using direct access to the struct memebers, since
structs is just a type similar to a class (with differences I know) why
should I allow direct access like that... I looked at the Size and other
parts on Control etc and I find its the same way by using property
accessors.

Seems to me people think struct = direct access, small, and easy.. Its just a type like all the rest (except with differences i Know blah blah) but why why why allow direct access. its just lazyness.. Code it once, and thats it, where is the saving? I mean if its coded well in the first place then you
dont have to keep engineering it so its not exactly a lot of work to use
those extra lines..

I also find ppl balk at the concept of using parameterized constructors and methods in a struct, theyre just not thinking .NET , and are thinking the
old way of structs on C. The object is still lightweight even tho there are methods, properties, and constructors..

I just hate lazy coding.

/End gripe.


You've hit the nail on the head with "and are thinking the old way of
structs on C".
Structs and unions are UDT's that predate the OO revolution. People who are
"into" OO will find the defaults associated with structs bothersome, as they
provide no OO benefits. From an OO perspective, struct defaults need a lot
of "fixing", but that's not always the context in which they're used.

--
Peter - [MVP - Academic]
Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.