Hi,
I don't like to use lazy instantiation of collection objects in properties (like in property
contracts of class
Costumer):
Code:
class Costumer
{
ISet contracts
get
{
#if LAZY_INSTANTIATION
if( m_constracts = null)
{
m_constracts = new ListSet();
}
#endif
return m_constracts;
}
}
ISet m_constracts;
Costumer()
{
#if !LAZY_INSTANTIATION
m_constracts = new ListSet();
#endif
}
ISet getContracts()
{
if (m_constracts = null)
{
m_constracts = new ListSet();
}
return m_constracts;
}
}
because the C# debugger calls all get-methods of properties in the debugger (in pane "local variables"), which causes side effects.
That's why I only use methods to perform lazy instantiation (like "getContracts()" ).
[Or is there an option to switch of the automatic property evaluation in the debugger? An alternative would be an attribute "sideEffect" to mark such properties.]
Because I generate my code in partial class definitions, I can't instantiate the collection objects in the constructor (as in class
Costumer) or in another central object initializiation method.
For my purposes it would be fine, if NH would interprete a null value in a collection variable (e.g. in "m_contracts") as an empty collection.
[A null value in a collection variable can only occur in a newly created object which is not already read from the database.]
Is this interpretation (of null value as empty collection) possible? - now? - maybe later?
Regards,
Mick