I'm dealing with a database table object that will contains all table info like fields name, table name, ecc.
That object have a method spawnRecord that will return a void record object that inherits from the table object.
The record object represent a single record of the db and have methods like load, update and insert. This allows to load a db record in the memory, to modify it and to update the same in the db.
Since I need to create many table objects and many record objects what is the most easy and clean way to do this?
I read the Douglas Crockford prototype approach, the classical approach, I tried to implement it but I get a lot of confusion and a code difficult to read.
preguntado el 09 de marzo de 12 a las 16:03
You can do this John Resig's way - a tiny script does many things -
1) multi level inheritance
2) 'instanceof' works as it should
3) call super class method from a subclass using 'super'
4) provide a constructor etc.