New Article: Getting Started with ObjectSpaces

It seems that not everybody has a day-off; the MSDN Belux team published my new article: Getting Started with ObjectSpaces, thanks Tom! This article starts with a description of what Object/Relational Mapping tools are, or at least I tried to explain it as clearly as possible. After that the article provides a step-by-step guide to a first ObjectSpaces article using the Mapper Utility. Topics like Spanning, Delay Loading, OPath are explained too. At the end there are some intresting links regarding ObjectSpaces, I'll post them here:

  • ObjectSpacesDemo source files, Schema Documents and SQL script
  • GotDotNet User Sample: ObjectSpaces PDC 2003 Samples and Mapper Utility
  • System.Data.ObjectSpaces Namespace documentation
  • Working with the ObjectSpaces Architecture
  • OPath Operators
  • 6 Comments

    • Is that really the SQL code that ObjectSpaces generates? This code doesn't seem like it would work in SQL Server 2000:



      Declare @r int, @e int;

      Set @r=@@ROWCOUNT;

      Set @e=@@ERROR;

      If @e = 0

      Begin

      if @r = 0 RAISERROR(''No rows effected'',16,1);

      If @r > 1 RAISERROR(''Change effected %d rows'',16,1,@r);

      End



      You need to set @r and @e in the same SELECT statement. Unfortunately, even a SET will reset those values.

    • A nice way to start the new year with a bang ! I guess this is the first article online that gives an introduction to objectspaces. And great that you use the mapper utility in your examples because this one makes objectspaces much easier to use than writing all this XML manually.



      My comments are only about the introduction :

      - There is at least one 'real-world' property that is easier to represent in a relational database than in an OO language : many-to-many relationships. This is easy to represent in an UML class diagram but once one starts coding you'll have to maintain collections on both sides of the relationship.

      - Real life taxonomies are sometimes difficult to map on current OO models. Like the well known example of geometrical figures : The class of squares is a subclass of the class of rectangles, nevertheless a rectangle has two properties (length and height of its sides) while a square has only one (because these lenghts are equal). Nevertheless, in the current OO implementations a subclass can only extend the number of attributes of its superclass. And this is only one example.

      - There are other database technologies that allow for an easier mapping with an OO runtime : object databases and XML databases. However, you're right in assuming that these are not widely used.



      Best greetings, Stefaan

    • Bill, I copied the SQL from the Query Analyzer of SQL Server 2000.



      Stefaan, thanks for your comments! How would you implement many-to-many relationships in a relational DB? It would require some additional helper tables I assume, so it would involve quite some coding.

      I agree that sometimes real life taxonomies are difficult to implement in an OO model: you provide a nice example. But I do think in general OO models can reflect better a real life situation. Btw, did you have a chance to try ObjectSpaces yourself, I'd love to share some thoughts! Enjoy the holiday, Jan

    • Yep, one uses an association tables for many-to-many relationships with at least the foreign keys of both related entities and possible some extra information about the relationship.

      And I agree that OO models and an OO centered middle-tier are great for the business applications must of us work on. But when used 'in the full richness of reality' it still has some limitations.

      And yeah, I played a little bit with ObjectSpaces at home. First without the mapping tool which was really hard because when one makes a mistake in one of the mapping files the error messages of OS are not very informative. Still didn't try the many-to-many relationships though.

      Would love to play more with this and share thoughts too ! :)

      Take care, Stefaan

    • Lucy! Please call me,Lucy! Please call me

    • Lucy! Please call me,Lucy! Please call me

    Comments have been disabled for this content.