SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Active Record pattern and extending classes

    I've been looking for but havn't been able to find any good information about extending classes that use the active record pattern.

    As a little background I'm a hobbyist programmer who learned procedural programming arround 96, but didn't really do any programming from 98-08. About 8 months ago i decided to try out some programming again so i started working in my spare time on a niche web based rss reader that passes feed items on to a download client based on some user criteria for a single user on a NAS like device. The application is not wildly popular, but i release about a version a month and it sees about 20 downloads a day.

    The application works well enough but it was coded in a procedural style and has become quite a mess as new features get added. I've decided to challenge myself to learn some modern OO principals and try and rewrite this mess of spaghetti into a coherent program consisting of dozens of simple, specialized, testable classes.


    To the subject though, i've found what i'm looking for is esentialy examples of class inheritance in an ORM and how they are handled, I cant really wrap my head arround how the queries would work to pull information from different tables to build the object. The thing that boggles my mind the most is the one-many when a user has a property, and the property can be classA, classB, or classC which all extend abstract class base. It seems all 4 classes should have their own table, with the base class having a one to one relationship with one of the 3 types, but always just one of the three. Does the base class table then need to have a seperate id column for each of the possible extending classes, or how can that be managed in a more efficient way.

    Interested in any ideas people might have. I've literally just started learning OO maybee two months ago, and OO patterns only two weeks ago. Picked up a pair of books and have been reading online about various patterns. I know php isn't necessarily the best for learning OO but my previous implementation was PHP and it seems silly to throw away all the code that has been previously written, even if i'm only reusing 30% as various complicated functions get broken into separate classes.

    ddringer

    edit; way too tl;dr, tried to shorten to moderate tl;dr
    Last edited by ddringer; Mar 29, 2009 at 03:49.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •