473,387 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

structs ...

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
4 1961

"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
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

"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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: James Pascoe | last post by:
Dear All, Apologies if this is OT. I have a C program which processes an arbitrary number of structs that are stored in a hash table. (The nature of the processing and the layout of the...
5
by: Paminu | last post by:
Why make an array of pointers to structs, when it is possible to just make an array of structs? I have this struct: struct test { int a; int b;
10
by: Angel | last post by:
I'm using several C functions (in a dll) that receive a struct as parameter. Since I'm doing it in C#, I assume I need to recreate the struct in C# in order to call the function with the required...
8
by: news.microsoft.com | last post by:
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...
5
by: Bilgehan.Balban | last post by:
Hi, I am currently brushing up my c++ knowledge and I would like to ask you about the differences between classes and C structs, in the function/method perspective. 1) Is it correct to say...
61
by: Marty | last post by:
I am new to C# and to structs so this could be easy or just not possible. I have a struct defined called Branch If I use Branch myBranch = new Branch(i); // everything works If I use Branch...
11
by: Cliff Martin | last post by:
Hi, I am reading a fairly large file a line at a time, doing some processing, and filtering out bits of the line. I am storing the interesting information in a struct and then printing it out....
29
by: Dom | last post by:
I'm really confused by the difference between a Struct and a Class? Sometimes, I want just a group of fields to go together. A Class without methods seems wrong, in that it carries too much...
43
by: JohnQ | last post by:
Are a default constructor, destructor, copy constructor and assignment operator generated by the compiler for a struct if they are not explicitely defined? I think the answer is yes, because...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.