News:

Pretty crazy that we're closer to 2030, than we are 2005. Where did the time go!

Main Menu

A C# Event Primer (for iago!)

Started by MyndFyre, October 16, 2007, 03:08:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Camel

If you pass a struct to a method in C#, the instance passed to the method is not the originating instance, because it is copied on to the stack. That means if you modify its state, the original object does not reflect the changes. Since this isn't how objects work in C#, even though structs are objects, it's confusing, breaks OOD, and is a hack.

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

MyndFyre

Quote from: Camel on November 12, 2007, 11:10:33 AM
If you pass a struct to a method in C#, the instance passed to the method is not the originating instance, because it is copied on to the stack. That means if you modify its state, the original object does not reflect the changes. Since this isn't how objects work in C#, even though structs are objects, it's confusing, breaks OOD, and is a hack.

But you're not invoking the behavior on the object.  You're invoking the behavior of another object using the state of the object in question.  And you're still confusing an object behavior with a semantic language behavior.  When you modify its state, you're modifying a new copy.

You say it breaks OOD.  Name six examples.
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

Camel

If structs are going to outright violate the rules defined for a System.Object, but they are still defined as a subclass of System.Object, that's a clear violation of OOD. If you are seriously going to sit here and tell me that behavior is restricted to state transitions of the instance, you should consider giving some of those certifications back.

Here are the six examples you asked for:
int i = 1;
long l = 1234567890;
double d = 42.1;
float f = 0.5;
byte b = 127;
char c = 'X';

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!