I've started reading a book on object oriented design and I started thinking ahead a bit and have a question on object persistence.

The current discussion is about inheritence and its using the example of people objects having certain attributes and behaviors and then certain subgroups of people (say, teacher or student) have specialized attributes and behaviors on top of those they inherit as being people. So even though I'm in chapter one and we are just talking in abstraction, my mind moves off toward how I might implement some of this in code... specifically how would I handle persistence.

If I implement an person object, with all its attributes and methods, I would persist it as a table with colums for each of the attributes and methods for accessing them and performing its actions. If I then create a student object that ISA person, do I create a new table that has all of the person and student attributes or do I have two tables, one for inherited data and one with new data and join on an object id? Or am I confusing layers here... persistence should be kept separate from behavior and attributes or maintained on the lowest level of inheritence to avoid confusion?

As a extension: from a DB perspective, if a chuck of info is someting that you would logically normalize into its own table, does that suggest that it should be its own object?

Thanks,

Jimbus

Never moon a werewolf!

In reply to OO design and persistence by jimbus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.