One of the most innovative things about ObjectSpaces is the fact that your business entities are not required to inherit from any base class.
With every persistence framework I have worked with – this has always been a requirement. As in this example, EntityBase would provide your O/R mapping and persistence functionality:
public class Employee : EntityBase
{
private int _ID;
private string _fullName;
public int ID {get {return _ID;} set{_ID = value;}}
public string FullName{get {return _fullName;} set{_fullName = value;}}
public Employee()
{
}
}
By not requiring use of a base class – I think Microsoft has done a great job keeping ObjectSpaces as thin and transparent as possible.
How was this accomplished?
The ObjectSpace classes (driven by map files) consume your custom classes, instead of providing functionality through inheritance.
For example to retrieve an employee,
ObjectSpace os = new ObjectSpace("map.xml", conn);
ObjectReader reader = os.GetObjectReader(new ObjectQuery(typeof(Employee), "ID = 1234’"));
Employee myEmp = (Employee) reader.Current;
Very nice. However, you might say… how is this considered thin? I’m used to instantiating business objects as easily as this:
A) Employee myEmp = new Employee(id);
OR
B) Employee myEmp = Employee.GetByID(id);
Well, the good news is… if you have been using a factory design pattern to instantiate your biz objects (as in B) – then you will be able to encapsulate all of the ObjectSpace classes within your static method (GetByID):
Similar to this,
public class Employee
{
private int _ID;
private string _fullName;
public int ID {get {return _ID;} set{_ID = value;}}
public string FullName{get {return _fullName;} set{_fullName = value;}}
public Employee()
{
}
public static Employee GetById(int ID)
{
ObjectSpace os = new ObjectSpace("map.xml", conn);
ObjectReader reader = os.GetObjectReader(new ObjectQuery(typeof(Employee), String.Format("ID = {0}", ID)));
return((Employee)reader.Current);
}
}
So, if you have been using a factory creational pattern – perhaps the developers consuming your business objects need not be aware of a conversion to ObjectSpaces at all…. Seems pretty tight to me. Of course, I have not seen examples of inserts/updates using ObjectSpaces yet. Please comment!
-Mike
PDC presentation , Lucas Bolonese on ObjectSpaces.
In the fall of 2002 I began exploring travel opportunities related to my .net consulting career. This was the result of a desire to travel, but also I think -- simply hedging my bets against a faltering economy.
.NET contract opportunities in London (www.jobserve.com) were, and are, pretty incredible. Much better than here in Atlanta - probably on par or better than NYC.
It was very important to me to not be tied down to a particular consulting house. Luckily, the UK has a special visa program called the Highly Skilled Migrant Programme. Through this program, select candidates can become authorized for 'permit free' consulting. Its a pretty interesting point system based on education, experience, earnings, etc... The idea is that you need to prove you are adding needed skills to their economy, rather than competing with their workforce for jobs.
After applying in Oct 2002, I finally received my HSMP visa in March 2003. After wrapping up things with my last client - it seems LondonTown is calling !!
I will be in London Dec 15 - 22 to hopefully track down a contract to begin early 2004. I will document my journey here.
I'd enjoy reading feedback from anyone who has or is considering a similar move...
One more good link for anyone interested: Immigration Discussion Board.
-Mike