Monday, April 28, 2014

Undefined vs. Null

Was asked this. Presumed it's JavaScript. Answer here: http://saladwithsteve.com/2008/02/javascript-undefined-vs-null.html
Basically one must keep in mind that an uninitialized variable (var a;) is undefined NOT null.
To be accurate when comparing, i.e. if to determine whether is undefined (unset) or null (set to null) use ===, i.e. if (a===null) or if (a===undefined); don't use (a==null) because that will be true regardless of null or undefined due to type coersion.

Saturday, April 19, 2014

Singleton vs. Transient

In the context of an IoC container (see http://docs.castleproject.org/Default.aspx?Page=LifeStyles&NS=Windsor&AspxAutoDetectCookieSupport=1) singleton is created once and reused for injection to dependent components when needed. Transient dependencies are created anew each time they are injected. Transient objects are released when the dependent object is released unless the dependent object is the root of the graph (the root of the graph is not managed by the container), i.e. Resolved explicitely -- in which case the transient must be Released explicitely or face potential memory leaks.

The transient keyword in the context of Java indicates to the writeObject method of the ObjectOutputStream that the field should not be considered part of the object state and thus not serialized.