Author Topic: A C# Event Primer (for iago!)  (Read 21369 times)

0 Members and 1 Guest are viewing this topic.

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: A C# Event Primer (for iago!)
« Reply #60 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.

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

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: A C# Event Primer (for iago!)
« Reply #61 on: November 12, 2007, 01:35:58 pm »
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.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: A C# Event Primer (for iago!)
« Reply #62 on: November 13, 2007, 12:08:26 am »
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:
Code: [Select]
int i = 1;
Code: [Select]
long l = 1234567890;
Code: [Select]
double d = 42.1;
Code: [Select]
float f = 0.5;
Code: [Select]
byte b = 127;
Code: [Select]
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!