<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Luca Bolognese's WebLog : Object Orientation</title><link>http://blogs.msdn.com/lucabol/archive/tags/Object+Orientation/default.aspx</link><description>Tags: Object Orientation</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How much object relational framework do you really need?</title><link>http://blogs.msdn.com/lucabol/archive/2004/08/06/209931.aspx</link><pubDate>Fri, 06 Aug 2004 16:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:209931</guid><dc:creator>lucabol</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/lucabol/comments/209931.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lucabol/commentrss.aspx?PostID=209931</wfw:commentRss><description>&lt;P&gt;It is always interesting for me to look at debates about object relational layers. I propose we define different levels of object relational support:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;No support: all the objects are persisted and queried by writing ADO.NET code by hand&lt;/LI&gt;
&lt;LI&gt;Code generation: you run a tool on your database (or on an abstract description of your schema)&amp;nbsp;and the tool generates a bunch of objects for your tables and some ADO.NET code to retrieve/persist their state&lt;/LI&gt;
&lt;OL&gt;
&lt;LI&gt;Total code gen: the tool generates all the ADO.NET code&lt;/LI&gt;
&lt;LI&gt;Partial code gen: the tool generates just code to intercept property accessors and provide delay loading, but all the data access code is in a separate compiled component&lt;/LI&gt;&lt;/OL&gt;
&lt;LI&gt;Metadata based: no code generation phase. The access to fields and property goes through reflection and the data access code is not exposed in the user code&lt;/LI&gt;
&lt;OL&gt;
&lt;LI&gt;Semi transparent: the persistent classes or properties need to be marked in some special way to be persisted (attributes, inherit from a special class or such...)&lt;/LI&gt;
&lt;LI&gt;Transparent: the classes don't need to be modified at all to be persisted&lt;/LI&gt;&lt;/OL&gt;&lt;/OL&gt;
&lt;P&gt;Things get fuzzy, though. It is sometime unclear the difference between 2.2 and 3.1 and&amp;nbsp;various creative solutions can be hard to classify. But in a general sense,&amp;nbsp;this classification is probably about right.&amp;nbsp;In a generic sense EJB1.1-2.0 is a 2.2, EJB3.0 is a 3.1, JDO is 3.2 (if you don't consider post-compilation) and ObjectSpaces is a 3.2. Hibernate and Toplink are squarely 3.2.&lt;/P&gt;
&lt;P&gt;But do you really need to go all the way to 3.2? All the times? I'll try to post more about trade-offs in all these solutions, but if you have an idea of a better categorization, please let me know. The one I propose is right out of my head and I'm not to happy about it either.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=209931" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lucabol/archive/tags/C_2300_+Programming/default.aspx">C# Programming</category><category domain="http://blogs.msdn.com/lucabol/archive/tags/Object+Orientation/default.aspx">Object Orientation</category></item><item><title>Book: "Objects, Components, and Frameworks with UML", Fedmond F. D`Souza</title><link>http://blogs.msdn.com/lucabol/archive/2004/08/03/207281.aspx</link><pubDate>Tue, 03 Aug 2004 20:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:207281</guid><dc:creator>lucabol</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/lucabol/comments/207281.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lucabol/commentrss.aspx?PostID=207281</wfw:commentRss><description>&lt;P&gt;This is a &lt;A href="http://www.amazon.com/exec/obidos/tg/detail/-/0201310120/qid=1091563751/sr=8-2/ref=sr_8_xs_ap_i2_xgl14/002-4177789-5140026?v=glance&amp;amp;s=books&amp;amp;n=507846"&gt;book &lt;/A&gt;about Catalysis, an OO methodology. I read this book some time ago (like years...). It is a quite complex book. If you don't like methodologists, it will easily put you to sleep. But if you stay awake, it is worth it.&lt;/P&gt;
&lt;P&gt;It is strange how this book crystallized one concept for me:&amp;nbsp;the definition of an interface. An interface is not just the sum of the signatures of the methods. It is a conceptual framework. The only way to fully describe it is to describe in a formal way this conceptual framework. For example without further specification it is impossible to know how to use this interface:&lt;/P&gt;
&lt;P&gt;interface IBook() {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; void AddPage(IPage p);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;What happens when you add a page? Will it add it at the end of the book? At the start? What happens if you call the method twice? Will the pages be in order? Will they be in the same section? Is there a concept of a section?&lt;/P&gt;
&lt;P&gt;There are ways to&amp;nbsp;make explicit&amp;nbsp;the implicit model beyond an interface: the one that&amp;nbsp;I've commonly seen being used is documentation.&amp;nbsp;The book argues for&amp;nbsp;formal contracts (preconditions, postconditions, invariants). The latter is certainly more formal, but to use it you need to describe formally what is the state beyond the interface and how the different methods affect this state. It is a lot of work.&lt;/P&gt;
&lt;P&gt;Is it worth the effort? I guess it depends on a zillion things like: the type of project, the people involved, ...&amp;nbsp;I don't think anybody is actually doing it, but it is still a good conceptual framework to keep in mind when you define your interfaces: it is not enough to write down the signature methods, you have somehow to expose the conceptual framework (where somehow means more or less formally).&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=207281" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lucabol/archive/tags/Object+Orientation/default.aspx">Object Orientation</category><category domain="http://blogs.msdn.com/lucabol/archive/tags/Books/default.aspx">Books</category></item><item><title>Please the perfect object stand up!!</title><link>http://blogs.msdn.com/lucabol/archive/2004/07/27/199102.aspx</link><pubDate>Tue, 27 Jul 2004 22:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:199102</guid><dc:creator>lucabol</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/lucabol/comments/199102.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lucabol/commentrss.aspx?PostID=199102</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;I always thought: why people write this very long posts? Here you have it.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;How do I design my objects? What is the set of constraints that dictate my design decisions? People talk about objects in very different contexts. A certain amount of confusion derives from not identifying the contexts for our objects.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;First, kings of them all, there are &amp;#8220;business objects&amp;#8221;. My library is full of OO books that describe how to design these guys. We have patterns and anti-patterns. Everybody is out there promoting their own methodology. But if we go deep enough, the most important design task in creating them is assigning responsibilities. This concept is as old as OO itself; it finds its roots in CRC cards. But I digress. Once again, when you design your business objects you have to be very careful to assign responsibilities to the objects that have the right information to perform them. &lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;It would be nice if this was all you have to code. A crazy bigot (like me) would think that all the rest is infrastructure (ala &lt;A href="http://www.nakedobjects.org/"&gt;naked objects&lt;/A&gt;). But we live in the real world, so let&amp;#8217;s get down to it.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;A second category of objects I often encounter are &amp;#8220;network objects&amp;#8221;. These are the guys you use to communicate data across tiers (logical, physical, webservices&amp;#8230;). They are usually quite dumb objects, not too much logic in them (if any), and your application creates them by filling their properties from the more noble business objects. Something along the line of the &lt;A href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html"&gt;value object pattern&lt;/A&gt;. Is assigning responsibilities a very important task here? Heck no!! They don&amp;#8217;t even have methods!! The most important characteristic they have is bandwidth optimization; you want to retrieve a whole bunch of stuff in one single round trip. More often than not you sacrifice everything else (manageability, good design &amp;#8230;) to achieve that.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;This is why I don&amp;#8217;t believe the quite common ideal of remoting your business objects. The set of constraints you use to design them is completely different (often opposite) to the constraints needed to go over the wire. When anything goes over the wire it becomes just data. Moreover not all of your business state needs to go on the network, but this is another story&amp;#8230;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Another common object category is &amp;#8220;database objects&amp;#8221;. There is a big debate if they are the same as business objects or not. I dont' want to go there, but ... If you want them to be the same you usually pragmatically sacrifice a bit of OO purity to make them more similar to the database tables (you don&amp;#8217;t want to fight your object relational mapping layer, you want to help it out). To say this in a more positive way, you design your domain model with an eye on how you are going to persist it. If, on the other end, you are willing to create a separate set of objects to represent data coming from the database, then the main constraint for these guys is the same as your database tables: normalization. This is not surprising as they are mirrors of your database. Again assigning responsibilities and being network friendly take the back seat in this case.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;There are many other object categories I often found useful (i.e. fa&amp;#231;ade objects). I don&amp;#8217;t want to discuss all of them here. Things are already boring as they are. The central point is that it is very hard to&amp;nbsp;define generic guidelines that work well in all the different contexts. You got to think about your context first.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;The funny thing is that I work in a place where we are supposed to design features that are generically interesting in all these scenarios. You use C# to code all of them. Oh well, design is the art of choosing trade offs&amp;#8230; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=199102" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lucabol/archive/tags/C_2300_+Programming/default.aspx">C# Programming</category><category domain="http://blogs.msdn.com/lucabol/archive/tags/Object+Orientation/default.aspx">Object Orientation</category></item></channel></rss>