Caught Using Inheritance!

don’t fall off your chairs…

re: ” I have in the past had long debates over whether or not the domain

object should know about persistence at all.” (Agile Modeling forum)

but i have *successfully abused inheritance* in the past to achieve an

interesting mix (for thin client/web apps).

  • Xyz Domain Class
    • can live on server or client
    • has the usual: properties and accessors
    • business methods
    • associations to other objects
    • often employs lazy loading
    • knows NOTHING about DBs
  • Xyz Business Class
    • INHERITS from the Domain Class
      • Gets all of the class properties that way 🙂
    • Knows about persistence classed (DGs/DAOs)
    • has the persistent ID
    • can get itself from the DB via an ID
    • can save() itself to DB
  • Xyz Transfer Object
    • small thing to meet some need of going between UI and server
    • used typically when the Domain Object is too big and you

      want specialized sets of properties filled in

  • Xyz Identifier Class
    • really tiny thing
    • usually just an ID and a string
    • sometimes a few other things
    • used for lightweight lists of associated classes
      • to drive drop-downs
      • typically used in conjunction with lazy loading

<gulp> there, i’ve confessed.

7 thoughts on “Caught Using Inheritance!

  1. Anonymous

    This is the most inane, boring and self-serving blog site I have ever encountered. I also notice the dearth of comments for all the postings. Sadly, this comment increments the count.

  2. Anonymous

    this blog has nothing to do with reality let alone successful S/W development practiced. this is pendace at its finest.

  3. Jon

    Hi Age, Dr O, and other veda-ans! Seeing your names brought a smile to my face. Many fond memories of learning under your tutelage.

    Feel free to discuss any BS on the site. Happy to hear any specific comments. (Unless you meant the prior 2 comments being BS.)

    To the other rude anonymous comments…

    Apr 9th: feel free to find more inane blogs — or i’ll take solace in being the most inane as that is a first place of sorts. Anyway, happy to hear your comments on specific items, leave your name and your blog, and please be civil. When I used to blog more frequently and plug my blog, I got ~34K hits per month… Admittedly, I have been too busy to keep the blog captivating my prior audience… Or maybe my recent posts just suck.

    Apr 11th: what specific points are against successful s/w development or reality? And what does “pendace” mean? I could not find it in or google. Id be obliged to learn your noun so I don’t accidentally miss the real slur when it comes around.

  4. Paul Oldfield

    Sorry, I used to be a regular reader, but pressure of work got in the way… that might account for 2 or 3 of the missing hits per month.

    Btw, I used an ObjectReference class rather than an Xyz Identifier class – had an objectID and something to id the class too. Invoke any method and it pulled in the real object. (in Smalltalk – maybe this would be harder in C++?)

  5. Thomas Eyde

    Why do you separate the business and domain object? I am all for separation of concerns, but from reading this post, the separation seems a little artificial. However, I like the idea of the identifier and transfer classes.

  6. Jon

    Thomas, the reason that Business & Domain Objects are different are indeed artificial. I first did this in 1995 on my first major thin-client, C++ project (IBM outsourced development of their 2nd generation Manufacturing Execution System). The Domain Objects needed to live on the client and the server. However, to live on the client, they could not have any reference to server libraries/methods (such as persistence libs). Hence the separation… Business Objects live on the server and can have server API calls. Domain Objects can live on either “side” of the “wire.”

    Hope that helps explain it a bit more…

Comments are closed.