7
shouts

Stop Using Structs Everywhere

posted by KodefuGuruKodefuGuru 282 days, 16 hours, 43 minutes ago
Tuesday, June 09, 2009 5:19:00 PM GMT

One thing that really gets under my skin is the overuse of structs. I hear arguments such as "structs are simple", "I don't have to instantiate it", or my personal favorite, "this is just a record." A struct can be complex, not instantiating something is not a good excuse, and structs are not "records" (usually this comes from Delphi programmers).

A struct should represent a single value. If it doesn't represent a single value, it shouldn't be a struct. That's the general guideline I follow when dec...

category: Architecture | clicked: 8 | | source: www.kodefuguru.com | show counter code
tags: C#

2 comments posted.

  • url Tuesday, June 09, 2009 6:35:16 PM GMT

    https://me.yahoo.com/mosessaur#7fe0dhttps://me.yahoo.com/mosessaur#7fe0d 282 days, 15 hours, 27 minutes ago said:

    I didn't go through the content yet, but stopping using structs, NO WAY. There are situations where structs are exactly the right solution.

  • url Tuesday, June 09, 2009 7:28:48 PM GMT

    KodefuGuruKodefuGuru 282 days, 14 hours, 33 minutes ago said:

    I do agree (and so does my article). The right situation for using a struct is to represent a single value. An entity should be a class.

To post your comment please login or signup