1 Reply Latest reply: Apr 14, 2010 6:25 AM by Hoek RSS

    Objects: should I use them? I like the idea,but will it be helpful overall?

      I'm thinking of writing an example of a banking system as a way to further my oracle knowledge.. Having installed XE and ODAC/ODT11 I started looking at the Object side of things last night (never knew it existed before) because I do most of my work in OO languages..

      Taking the very simplistic view that an Account has some attributes (name, accountnumber, branchnumber) and a list of Cards that can access the account (the cards have attributes such as cardnumber, expirydate, name) I created Account and Card types, a nested Cards type which was a TABLE OF Card, and made new object table to shove a few test Account in. (Account has a Cards nest list)
      Later, there would be a Transaction object that has a Card, amount, date etc and I presume an object table of Transaction will exist into which I will put all the Transactions..

      but then herein comes my question: is this a helpful way of organising the system? If my Transaction object had a Card column, is it actually the same Card as exists in only one place in any of the nested Cards tables of Account? How do I ensure I never make a Card with the same number as another Card? How to I associate a particular card with a Transaction? If Card had a performTransaction(amount) method, would it be responsible for putting an entry in Transaction object table, along with the concept of "this" (from oo languages.. i.e. the current object instance)

      In RDBMS terms I'd have CARDS table, with a primary key on card number, and an account number column to say which account the card belonged to - how does such a restriction work with Objects? Suppose then I had a row out of a TRANSACTIONS table, it has a card number; using that I can inner join to cards to get the card info. Does objects make this implicit and easier, and more sensible, by storing a ref to the actual card in the Transaction? Can I take that Card out of the transaction, and ask it what its owning account is? (In RDBMS style its TRAN join CARD join ACCOUNT..). When performing a transaction, I would write the card number into the transaction table row and therefore I have associated this transaction with the only ocurrence of that card number in the system.

      I kinda see Objects as essentially a load of tables and hidden columns, and hidden implicit joins, which might make things a lot easier. Do I then run into a problem though, manipulating these things in .net? I know how to write queries in .net; comfortable with that.. But if someone came to me and said "In the object framework you just created, find an account and list all its cards, in .net" - how is that done?

      Are objects in this sense, going to make my life easier? Can I write a method on a card that returns me the available funds, by summing this card's funds and the parent account's funds (supposing that they can each hold funds)? What must be done to give card visibility of its parent? I suppose, like a normal OO language, Card would have to accept an instance of Account in its constructor (after all the CARDS table in RDBMS style has an AccountNumber column)..

      In terms of space and resource usage; is Objects fast to work with? Would a banking system written in objects use more space vs classic rdbms? (I read a lot of posts that say: "well, objects is just oracle masquerading a load of hidden tables and joins - why would you want to reduce the flexibility when you can have the tables and do the joins yourself" - there has to be some scenario where objects has an advantage over managing the o/r mapping myself)