Structures
- Structure is a lightweight alternative to class
- Structure is of Value type(Which means it requires boxing/unboxing when transform value type to reference type and is created in the stack rather then the heap)
- Not fully supports inheritance(can inherts only from an object and is implictily sealed)
- Can not have default constructor nor destructor
- From [From Java to C#:A developer's Guide] Charapter 26.3,You should choose to use a struct rather than a class for performance reasons. If you are writing a class that:
represents a small data structure with few data members, and
it is convenient for it to be a value type instead of a reference type
Being a value type, an assignment results whole struct's value to be copied over, this might cause performance issues.
- Serializable & MarshelByRefObj
- A object marked as [Serializable] is passed by value.
- A object inherits from MarshelByRefObj is passed by reference, which means, when deserializing, client gets a proxy rather then an object.
- LINQ to SQL - About Data Corruption
- [Chapter 15.2, LINQ to SQL Fundamentals]...LINQ ensures that multiple retrievals of a database record are represented by the same object instance; this makes it much harder for the aforementioned scenario to occur......" that would be reflected in Joe's representation of the object—they are looking at the same data, not at independent snapshots...
- What if they are accessing the data from different process (can't be same object if LINQ does not provide an independent mempry storage) ? is the above stetments still sustain ? Require further tests.
沒有留言:
張貼留言