"Joanna Carter (TeamB)" <jo*****@nospam forme.com> wrote in message
news:uN******** ******@TK2MSFTN GP09.phx.gbl...
"Richard Blewett [DevelopMentor]" <ri******@NOSPA Mdevelop.com> a écrit
dans
le message de news: #r************* *@TK2MSFTNGP14. phx.gbl... You forgot one - and this is the reason for their existance - With no
boxing, structs are faster and smaller which is why all the primatives are
valuetypes and things like System.Drawing. Point
Indeed Richard and Joanna.
I added that last tidbit that structs sucks just for letting someone make
this point (about Points *S*).
However, I think there is seldom reason for defining your own value types.
Every time I start by thinking of a type as a struct I usually wind up
making it a class. I typically ask my self, - Can I assure that an instance
of this type won't be passed to a method as an Object. Most structs seldom
pass that test.
I think structs will be more used in .NET 2.0 as generic types as List<T>
and such will cope with the boxing problem. When this happens I think people
will use structs for business entities and data entities, and not interfaces
as Java typically does things.
I'd rather see a Customer as a struct and not an class or interface. The
struct says - "I am a customer and I do this and that and I am written in
stone so you can always expect the same behavour from me!" I think this
makes more sense than having an class go: - "I am perhaps a customer or
something more special than that and I may do what you expect if not
something completly overriden." Interfaces though are worst in my view: - "I
am sorta like a customer and I behave in a customerlike way. But exactly
what I do is hidden from you and may change at anytime depending on the
factory that (perhaps) loaded me dynamically. You'll never know!"
In of .NET 1.1, I don't use structs for the above purposes as it's
performance problem in regards to boxing is quite costly.
As I have always admired your articles and posts in the delphi OO group,
Johanna; I hope you comment on the above.
- Michael S