I am new to object oriented programming and slowly learning how to apply it to javascript. So please bear with me. :)
I have two main objects:
A “record” that contains methods for editing a single record from a set of records. (create, save, load, etc.)
"recordList", which contains the output methods of the paginated list of record names.
I would like these objects to work together. For example, if record.save () is called, recordList.refresh () is also called, so the broken list reflects the updated data.
To do this, I created a third “control” element, which contains instances of both “record” and “recordList”. I use "control" as follows:
control = {} control.record = object.create("record"); control.recordList = object.create("recordList"); control.save = function() { this.record.save(); this.recordList.refresh(); };
It works. But I wonder, right? (I want to make sure that I don’t violate any OO design rules at the same time.) Is there a better way?
Thanks in advance for your help.
javascript oop
Travis
source share