<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Domain Objects</title>
        <link>http://blogs.sftsrc.com/jeffm/category/22.aspx</link>
        <description>Domain Objects and how to use them</description>
        <language>en-US</language>
        <copyright>Jeff Mayeur</copyright>
        <generator>Subtext Version 2.1.1.1</generator>
        <item>
            <title>Domain in the Box Part 4</title>
            <link>http://blogs.sftsrc.com/jeffm/archive/2007/10/28/81.aspx</link>
            <description>&lt;p&gt;Roles? This is definitely one of the areas I've had the most trouble with when I try to understand my fictitious Plebian U Domain. In my original model, roles defined both a person's relationship to the University either employee (of a specific type ex, Professor, Adminstrator, GroundsKeeper etc) or student (graduate, undergrad, post-grad), and status/ fulltime and part time. On my original person object there was no concept of a Roles list (it was build on .Net 1.1, so no generics). The way I had built my layers, the BLL would call into the DAL with a specific RoleID and get back a list of all people in that role. &lt;/p&gt;
&lt;p&gt;In this retouching of my Bag-O-Tricks I'm planning on using LINQ in the BLL to make those types of selections. This gives me 2 benefits, 1&lt;sup&gt;st&lt;/sup&gt; if a person does have multiple roles I know long will need to load the same exact person record up more than once, and second I think I'll be able to simplify the scope of the Role domain object. The big problem that I've always had with my original approach is that I felt that the Role object was really trying to encapsulate 2 distinct pieces of data. 1&lt;sup&gt;st&lt;/sup&gt; the PersonToUniversityRelationShip and 2&lt;sup&gt;nd&lt;/sup&gt; the PersonEmploymentType or PersonStudentType. Right now I'm basically looking at Role to define a person as an Employee, a Student or both. &lt;/p&gt;
&lt;p&gt;In fact I'm not even sure that I'll have a Role object in my finalized Domain, in some ways it's a vestige of past incarnations, like the appendix, that while it might not cause any issues may not serve any real purpose. The data that I'm really going to care about is going to shift to two new domain objects tentatively called PersonEmploymentStatus and PersonEnrollmentStatus. I'm inclined at least at the Database layer so that I can use FK's to constrain the values. The status tables will let me define the attributes like type of Employee as well as more detailed information like what Colleges is the person associated with. &lt;/p&gt;
&lt;p&gt;I'm not entirely sold on this yet, but I think that in the end I will go away from using Roles and just use LINQ to JOIN the Status objects with the Person objects to get the specific Employee and Student records. Some of that will be shaken out when I start to flesh out the Status objects and see how they relate to the EmplomentHistory and StudentHistory records that I had in my original Domain set, but I'm not in too much of a hurry to choose, the PersonRole class I have is very small, and using the Generate Unit Tests facility of VS 2008 Beta 2 makes very short work of the unit test for these objects. &lt;/p&gt;
&lt;p&gt;Currently I have only this for my PersonRole object: &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;PersonRole &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt;? RoleID { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; RoleName { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; RoleDescription { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PersonRole() &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PersonRole(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;? roleID, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; roleName, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; roleDescription) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.RoleID = roleID; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.RoleName = roleName; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.RoleDescription = roleDescription; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt;thing that has always been difficult for me when I try to extract the individual entities from the domain, is knowing just how far to break things down. Think about something like a Date, in truth a Data can be thought of as three separate objects, a Month, Day and Year. In fact it wasn't on common in the days before Ajax Calendars to create a Data as either 3 separate Text-Boxes or Drop-Down Lists. Sure on the server side these fields are usually recombined to create a full Date object, but it's not inconceivable to consider the constituents as independent objects, especially for specific validation requirements, like verifying that a Date is on a Monday or Thursday. &lt;/p&gt;
&lt;p&gt;Now I have never seen, nor would I ever recommend splitting out the a Date into 3 separate Domain objects. However I have seen ActivityDate as a fully fledged Domain object. Every table that needed to store an Activity Data would make an entry In the FKeyed Activity table, and the ActivityDate consisted of a UserID, DataTime and ActivityID. In this case the abstraction made some sense based on the reporting requirements of the System. One report that was given a very high deliverable rating was the ability to at a glance see what employee had performed what actions for a given Date Range. Sure each table could have an ActivityDate field, and some report could do multiple selects and compile the results, but for both efficiency and ease of maintenance it made sense to create a fully fledged entity. It made even more sense to push this into the Domain, as it made it very clear to all consumers of the Domain objects that the Activity tracking was really a first class object. &lt;/p&gt;
&lt;p&gt;For this project both the first time I looked at this, and this time the Roles area really was one of the places where I struggled the most to find a clean set of fault-lines to traverse. Sure there were other areas where I could vastly improve my design, but none where I felt quite as unsure. Hopefully as I work into the BLL of this project I will start to recognize the signs of a good clean set of domain objects.&lt;/p&gt;&lt;img src="http://blogs.sftsrc.com/jeffm/aggbug/81.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jeff Mayeur</dc:creator>
            <guid>http://blogs.sftsrc.com/jeffm/archive/2007/10/28/81.aspx</guid>
            <pubDate>Mon, 29 Oct 2007 05:18:45 GMT</pubDate>
            <comments>http://blogs.sftsrc.com/jeffm/archive/2007/10/28/81.aspx#feedback</comments>
            <slash:comments>40</slash:comments>
            <wfw:commentRss>http://blogs.sftsrc.com/jeffm/comments/commentRss/81.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Domain in the Box Part 3</title>
            <link>http://blogs.sftsrc.com/jeffm/archive/2007/10/26/79.aspx</link>
            <description>&lt;p&gt;So how to handle contact info, do I make a "type level" domain object like an Emergency or Home, or do I save that sort of logical grouping for the Business layer. Truthfully I've already made up my mind. The domain layer I'm updating doesn't make any groupings, and here's why. Essentially I tried to look at the domain objects as whole entities onto themselves. An email address really has nothing to do with a mailing address, and any association like "emergency" is purely a matter of interpretation. Another way to look at it is I didn't really want my domain layer making what I thought was a business decision to allow something like an emergency email. It's the prerogative of the BLL to decide what Types of each entity the system can created. Perhaps for the grouping of emergency the BLL determines that Phone-Number is the only valid entity to create and maintain. &lt;/p&gt;
&lt;p&gt;So if that sounds like a reasonable approach then it's not too hard to draw out where I'm going next. One change I've made though is to switch to Nullable&amp;lt;int&amp;gt;s for my IDs. I originally created this domain set in .Net 1.1 so that really wasn't a possibility. But now that I can, it can become a nice way to track new domain objects that must be persisted. This brings up a whole entire ball of scariness I haven't yet covered, how to track the dirty state of an Domain object, let me count the ways. First and foremost let me say that this is the sole potential benefit that I see in using DataSets instead of Domain objects, but it's not worth it by any means. &lt;/p&gt;
&lt;p&gt;Handling the notion of a Dirty object, is a touchy one topic, both because it can provide a fair number of challenges, and because there are so many preferred patterns to use. However generally I tend to cheat here especially when it comes to making any decision about whether to persist/update/delete a domain object I rely solely on the BLL to make the call. Because I generally try to follow a pattern where any UI, or API that can create or modify data has absolutely no contact with domain objects, I can push any state logic out of the domain layer allowing for a very simple model. I can't say if this is the best model, only that I like idea that a least one application layer can be very simple. &lt;/p&gt;
&lt;p&gt;So without further ado here's the ContactInfo Class and its constituents: &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ContactInfo &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt;? ContactInfoID { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;PhoneNumber&lt;/span&gt;&amp;gt; PhoneNumbers { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;Address&lt;/span&gt;&amp;gt; Addresses { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;EmailAddress&lt;/span&gt;&amp;gt; EmailAddresses { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; ContactInfo() &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; ContactInfo(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;? contactInfoID, &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;PhoneNumber&lt;/span&gt;&amp;gt; phoneNumbers, &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;Address&lt;/span&gt;&amp;gt; addresses, &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;EmailAddress&lt;/span&gt;&amp;gt; emailAddresses) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.ContactInfoID = contactInfoID; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.PhoneNumbers = phoneNumbers; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Addresses = addresses; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.EmailAddresses = emailAddresses; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;EmailAddress &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt;? AddressID { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Address { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Status&lt;/span&gt; Status { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; Order { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; EmailAddress() &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; EmailAddress(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;? addressID, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; address, &lt;span style="COLOR: #2b91af"&gt;Status&lt;/span&gt; status, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; order) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.AddressID = addressID; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Address = address; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Status = status; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Order = order; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;}&lt;/span&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;PhoneNumber &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt;? PhoneNumberID { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Number { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;PhoneNumberType&lt;/span&gt; PhoneNumberType { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PhoneNumber() &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PhoneNumber(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;? phoneNumberID, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; number, &lt;span style="COLOR: #2b91af"&gt;PhoneNumberType&lt;/span&gt; phoneNumberType) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.PhoneNumberID = phoneNumberID; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Number = number; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.PhoneNumberType = phoneNumberType; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Address &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt;? AddressID { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;AddressType&lt;/span&gt; AddressType { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Street { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; City { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; State { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Zip { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; Address() &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; Address(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;? addressID, &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt;AddressType&lt;/span&gt; addressType, &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; street, &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; city, &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; state, &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; zip) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.AddressID = addressID; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.AddressType = addressType; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Street = street; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.City = city; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.State = state; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Zip = zip; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;That's it not too much there, but next we'll look at the Roles side of the Person Tree. &lt;/p&gt;
&lt;p&gt;Okay one more distraction, although I'm not yet focusing on unit tests, I'm going to include some code that I often use to support my unit tests. This class is used to create a default instance of a complex object. With my current code base I don't have a lot of use for it, but I'd like to throw it out there as I know it will be useful to me later, and hopefully someone will be able to turn it into something much more useful. &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Object Creator &lt;/strong&gt;&lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;DefaultObjectCreator&lt;/span&gt;&amp;lt;T&amp;gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; DefaultObjectCreator() &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (_propertyValues == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;_propertyValues = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Hashtable&lt;/span&gt;(); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;_objectType = &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(T); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;DefaultObjectCreator&lt;/span&gt;&amp;lt;T&amp;gt; CreateObject() &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt;Assembly&lt;/span&gt; asm = &lt;span style="COLOR: #2b91af"&gt;Assembly&lt;/span&gt;.GetAssembly(_objectType); &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;object&lt;/span&gt;&amp;gt; args = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;object&lt;/span&gt;&amp;gt;(); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt;ConstructorInfo&lt;/span&gt; ctor = selectConstructor(_objectType); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;null&lt;/span&gt; == ctor) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ApplicationException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Could not match provided parameters to any Constructor"&lt;/span&gt;); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;ParameterInfo&lt;/span&gt; pi &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; ctor.GetParameters()) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (_propertyValues.ContainsKey(pi.Name)) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;args.Add(_propertyValues[pi.Name]); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;else &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;args.Add(getDefaultTypeValue(pi.ParameterType)); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;_createdObject = (T)asm.CreateInstance(_objectType.FullName, &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;BindingFlags&lt;/span&gt;.CreateInstance, &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;, args.ToArray(), &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;); &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;DefaultObjectCreator&lt;/span&gt;&amp;lt;T&amp;gt; SetValue(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; paramName, &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; value) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;null&lt;/span&gt; == _createdObject) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;_propertyValues[paramName] = value; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;PropertyInfo&lt;/span&gt; pi &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; _objectType.GetProperties()) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (pi.Name.ToLower() == paramName.ToLower()) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;pi.SetValue(_createdObject, value, &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;FieldInfo&lt;/span&gt; fi &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; _objectType.GetFields()) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (fi.Name.ToLower() == paramName.ToLower()) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;fi.SetValue(_createdObject, value); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ApplicationException&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: #a31515"&gt;"Could not find property [{0}]"&lt;/span&gt;, paramName)); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; T GetObject() &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;null&lt;/span&gt; == _createdObject) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;CreateObject(); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; _createdObject; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ConstructorInfo&lt;/span&gt; selectConstructor(&lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt; objectType) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt;ConstructorInfo&lt;/span&gt;[] ctors = objectType.GetConstructors(); &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (_propertyValues.Count == 0) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;ConstructorInfo&lt;/span&gt; ctor &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; ctors) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (ctor.GetParameters().Length == 0) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; ctor; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;ConstructorInfo&lt;/span&gt; ctor &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; ctors) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (ctor.GetParameters().Length &amp;lt; _propertyValues.Count) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;continue&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; found = &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; paramName &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; _propertyValues.Keys) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;ParameterInfo&lt;/span&gt; pi &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; ctor.GetParameters()) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (pi.Name.ToLower() == paramName.ToLower()) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;found = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;break&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!found) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;continue&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (found) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; ctor; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; getDefaultTypeValue(&lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt; paramType) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (paramType == &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;bool&lt;/span&gt;)) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (paramType == &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;)) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;.MinValue; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (paramType.IsValueType) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (paramType.IsEnum) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Enum&lt;/span&gt;.GetValues(paramType).GetValue(0); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (paramType.IsPrimitive) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; 0; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; createDefaultObject(paramType); &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; createDefaultObject(&lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt; objectType) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt;Assembly&lt;/span&gt; asm = &lt;span style="COLOR: #2b91af"&gt;Assembly&lt;/span&gt;.GetAssembly(objectType); &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;object&lt;/span&gt;&amp;gt; args = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;object&lt;/span&gt;&amp;gt;(); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt;ConstructorInfo&lt;/span&gt;[] ctors = objectType.GetConstructors(); &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;ParameterInfo&lt;/span&gt; pi &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; ctors[0].GetParameters()) &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;args.Add(getDefaultTypeValue(pi.ParameterType)); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; asm.CreateInstance(objectType.FullName, &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;BindingFlags&lt;/span&gt;.CreateInstance, &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;, args.ToArray(), &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;); &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Hashtable&lt;/span&gt; _propertyValues; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; T _createdObject; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt; _objectType; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;img src="http://blogs.sftsrc.com/jeffm/aggbug/79.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jeff Mayeur</dc:creator>
            <guid>http://blogs.sftsrc.com/jeffm/archive/2007/10/26/79.aspx</guid>
            <pubDate>Sat, 27 Oct 2007 05:47:07 GMT</pubDate>
            <comments>http://blogs.sftsrc.com/jeffm/archive/2007/10/26/79.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.sftsrc.com/jeffm/comments/commentRss/79.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Domain in the Box Part 2</title>
            <link>http://blogs.sftsrc.com/jeffm/archive/2007/10/25/78.aspx</link>
            <description>&lt;p&gt;*** Note I'm doing this post series using &lt;a href="http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx"&gt;Orcas Beta2&lt;/a&gt;. So most of my code samples will be using whatever new baked in goodness I can garner from new VS. So far I'm really amazed with this release of VS 2008, aside from awesome JavaScript Intellisense, and a generally lighter, faster feel, the big thing for me is that the 2 Deal Breaker issues I've had with the VS Unit Testing facilities have been fixed. As A long time &lt;a href="http://www.testdriven.net/"&gt;TestDriven.Net&lt;/a&gt; user, It was an absolute requirement to have a right click Run Tests, that would either execute a full TestFixture or single Test based on Context. Second was the ability to double click on the Error output and go straight to the line of Code that barfed. Glory be, they are both fixed (I always thought of them as bugs, not missing features), and I now am sold on the VS way, I am not worthy… &lt;/p&gt;
&lt;p&gt;The first part of the Plebian U domain I want to work through is the "person." I want to see if it's possible to encapsulate the full range of Employees and Students into a single object. I'm pursing this for my model as for the most part employees do not differ from students until the business logic layer. Sure employees get a salary or wage, and students pay tuition, but those are either actions of the University or students, not attributes of a person. &lt;/p&gt;
&lt;p&gt;There are differences to be sure, but I think that I can encapsulate those within the bounds of a Role object. This allows me to define a person who has 0-n Roles, and not have to maintain separate objects to represent the same actual person. Another key constraint I'm placing on myself is that I'm not going to be using Interfaces. This is partly to help maintain as simple of a structure as possible, and partly because I'm not worried about things like lazy loading or late binding. In general those are very useful considerations for a large application, but my overriding principle here is to have something I can very quickly customize to my current needs, without getting hung up on things like Versioning or configuration headaches that go hand in hand with those wonderful runtime typed domains. &lt;/p&gt;
&lt;p&gt;So I'm going to start by trying to identify everything that I think all employees and students have in common: &lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Names – First, Last and Middle&amp;lt;opt&amp;gt; &lt;/li&gt;
    &lt;li&gt;Date Of Birth &lt;/li&gt;
    &lt;li&gt;Unique Id – something the student/employee can use on forms (often this is an SSN, but I'm thinking more generic) &lt;/li&gt;
    &lt;li&gt;Status – Active, Inactive or Current/Former, I see the roll object distinguishing Full-Time or Part-Time &lt;/li&gt;
    &lt;li&gt;Addresses – Mailing, Home, Billing, Emergency, other, &lt;/li&gt;
    &lt;li&gt;Phone-Numbers – Residence, Cell, Work, Emergency &lt;/li&gt;
    &lt;li&gt;Email Addresses – Personal, Work, Emergency &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What about the differences, like the students' grades, or class schedule, or a professor's class schedule or Start Date? Those are all really just other Domain objects. Employees will have an EmployeeRecord, and students will have things like an EnrollmentRecord, CurrentSchedule, and Transcript. By keeping things simple like this I'm getting at least 2 benefits, first is the ability to have my domain follow a reasonable pattern of normalization, and second Flexibility. If I create a Person with Roles, and Contact info, and basic Bio info, I can use that person object in an application for say a Gym. A person really is just a person, and it's useful not to clutter the domain with specifics that are not really necessary. It should be the Data not the format that tells us what we need. &lt;/p&gt;
&lt;p&gt;Say I was making an application for an auto dealer. One of the objects I certainly have is a Car. It wouldn't make much sense to track something like "SellerID" as a property of the Car, it's totally unrelated. The same applies to our Person. A Person can do and posses many things, but neither the Actions, nor the Possession are actual properties of the Person. &lt;/p&gt;
&lt;p&gt;One thing I've done thought is decided that I want to encapsulate a Person's Addresses, Phone-Numbers and Email Address as ContactInfo. It's a natural division, partly following the idea above, and partly violating it. Since the U cannot have a Person without some ability to contact them, it's fair to make it a property of the Person. Yet as both a nod to flexibility and separation of Domains, I see benefit in pulling it off as its own group. I may be totally wrong about this, but here's how I see my person domain object. &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Person&lt;/span&gt;&amp;lt;T&amp;gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; PersonID { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;PersonReadableID&lt;/span&gt;&amp;lt;T&amp;gt; ReadableID { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Status&lt;/span&gt; Status { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;PersonRole&lt;/span&gt;&amp;gt; Roles { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ContactInfo&lt;/span&gt; ContactInfo { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; FirstName { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; MiddleName { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; LastName { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;? BirthDate { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt;Some things to note: &lt;span style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: Courier New"&gt;Status &lt;/span&gt;is an Enum; &lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt;PersonReadableID&lt;/span&gt;&amp;lt;T&amp;gt; &lt;/span&gt;will likely die an untimely death, I'm looking for a way to give a person a unique ID like an SSN, that we can persist with the person Record, and this gets me that for now, but I don't like it too much; &lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;PersonRole&lt;/span&gt;&amp;gt; &lt;/span&gt;is a placeholder, I haven't gotten to Roles yet, but I know I need them; &lt;span style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: Courier New"&gt;ContactInfo &lt;/span&gt;is also mostly just a stub, but here's a look at where I think I'm going. &lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ContactInfo &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; ContactInfoID { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;PhoneNumber&lt;/span&gt;&amp;gt; PhoneNumbers { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;Address&lt;/span&gt;&amp;gt; Address { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;PhoneNumber &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; PhoneNumberID { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Number { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;PhoneNumberType&lt;/span&gt; PhoneNumberType { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Address &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;{ &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; AddressID { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;AddressType&lt;/span&gt; AddressType { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Street { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; City { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; State { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Zip { &lt;span style="COLOR: blue"&gt;get&lt;/span&gt;; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt;; } &lt;/span&gt;&lt;br /&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier New"&gt;} &lt;/span&gt;&lt;br /&gt;
&lt;p&gt;With the Contact Info I'm not sure how I want to enforce grouping. IE should an Emergency Phone-Number and Address be treated as a single unit, or should it be the responsibility of the BLL to extract that info on demand, but that's for a later post, I've got some code, and some unit tests (won't bother posting most of those as they're very plain at this point).&lt;/p&gt;&lt;img src="http://blogs.sftsrc.com/jeffm/aggbug/78.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jeff Mayeur</dc:creator>
            <guid>http://blogs.sftsrc.com/jeffm/archive/2007/10/25/78.aspx</guid>
            <pubDate>Fri, 26 Oct 2007 05:36:43 GMT</pubDate>
            <comments>http://blogs.sftsrc.com/jeffm/archive/2007/10/25/78.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.sftsrc.com/jeffm/comments/commentRss/78.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Domain in the Box Part 1</title>
            <link>http://blogs.sftsrc.com/jeffm/archive/2007/10/24/77.aspx</link>
            <description>&lt;p&gt;This post series is going to cover the creation of a fairly simple creation of a set of Domain objects to cover the needs of a fictional Plebian University.  The goal will be to create a set of Domain objects that will service a "tracking system" that encapsulates the management of people and facilities for this university.  The set of posts will be centered on the Domain objects but we can't really fully develop those objects without knowing a little about how we want to approach persistence and how we want to handle business logic.
&lt;/p&gt;&lt;p&gt;Sure there are hundreds of examples of domain object creation, so why bother posting on it?  First because I need to update my canned &lt;a href="http://blogs.sftsrc.com/jeffm/archive/2007/10/19/Making-the-most-out-of-the-AjaxControlToolkits-ModalPopupExtender-Part.aspx"&gt;library&lt;/a&gt;.  Second because I want to take a deeper look at some of the stuff coming up in .Net 3.5.  Third because a lot of the examples use the Customer/Order/OrderDetail problem set, and while that set is rich, I think there's a little more complexity to be had in the classification of a scholastic institution.  And lastly, well because the point of a blog isn't necessarily always to have all the answers, rather sometimes it's about testing yourself.  Key to that notion is that I've always been a Web-Developer, at least at heart, and one of the big implications of that is the tendency to start the design process from the point of view of what the UI can possibly do.  In this case I really am going to try to stick to a true domain level mapping of my problem set, and not get bogged down to heavily in how I'm going to deal with the problems from the UI.
&lt;/p&gt;&lt;p&gt;One of the problems I like that the scholastic model presents is how to handle professors who are students, or students that are employees.  From a persistence (DB) level it's pretty easy to see a Person store, and a PersonRole store that allows multiple Roles per Person.   In the domain level I can choose to split these out into firm types, or more closely model the persistence layer waiting until the business object layer to make any distinction.  However we decided to cover that ground I want to make sure I can explain my reasons in plain English such that my fictional End Users will be able to comprehend both the correctness and implications of my choices.
&lt;/p&gt;&lt;p&gt;Another good problem is the idea of forced generalization.  Consider that a common scenario in our fictional university is the temporary repurposing of facilities.  Say a classroom that is being used for chair storage.  I need to be able to represent this room both as a classroom and as a storage room, so something like the Roles classification system seems logical, but what about rooms that are multipurpose such as storage and rehearsal space.  Or facilities that need to be reclassified solely on the basis of its current occupant like a yoga studio that's also a creative writing classroom and Daycare playroom.   How are we going to represent this type of flexibility while still providing a meaningful representation of the universities facilities, what's the role of the Domain and what's really a Business Logic Layer decision, these are the types of questions I want to answer.
&lt;/p&gt;&lt;p&gt;The other part of this series of posts is to help layout and examine the evolution of requirements.  Anyone with at least one project under their belt will know the humor found in the schedule marker "Requirements Complete".  To the best of my knowledge, there has never been nor ever will be a "requirements complete" state for any business software project.  For this post series I want to have an informal approach to requirements.  There'll be some high level requirements, but in general we won't flush them out until we're in a specific problem space.   Also the requirements will be focused on the Application level and not on the Domain.  Partly that's to make their expansion somewhat realistic, and partly to allow me to be vague in laying them out. 
&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Requirements:&lt;/strong&gt;
	&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The final Application needs to track all students and staff, full-time and part-time, exempt and non-exempt, current and former.
&lt;/li&gt;&lt;li&gt;The final Application needs to track all Colleges, both enrollment, usage of facilities, staff, and students who's major's fall into that college and students fulfilling requirements
&lt;/li&gt;&lt;li&gt;The final Application needs to track all facilities, both buildings and grounds.
&lt;/li&gt;&lt;li&gt;The final Application needs to track on campus student housing needs.
&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;Okay seems simple enough.  The plan is to break off each Domain object by itself, with some exceptions like Person and PersonRole type groupings.  Hopefully when this is done there'll be a nice set of domain objects we can use for future sample projects.  And the next set of posts will be consuming these objects in Business Logic Layer.
&lt;/p&gt;&lt;img src="http://blogs.sftsrc.com/jeffm/aggbug/77.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jeff Mayeur</dc:creator>
            <guid>http://blogs.sftsrc.com/jeffm/archive/2007/10/24/77.aspx</guid>
            <pubDate>Thu, 25 Oct 2007 05:14:35 GMT</pubDate>
            <comments>http://blogs.sftsrc.com/jeffm/archive/2007/10/24/77.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.sftsrc.com/jeffm/comments/commentRss/77.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>