Menu

#5 Deep object hierarchy

open
nobody
None
5
2002-08-02
2002-08-02
Aaron Hamid
No

Another feature I would like to request is the option of
embodying the parent/child relationships in generated
source by composition. That is, Parent classes should
have a collection of Children classes within them, which
would have accessors/mutators/adders/removers. This
could simply be a checkbox in the GUI: [x] Generate
nested objects.

For example the class for a Parent table might have
something like:

private Vector Child_list = new Vector();

public Vector getChildList() {
return Child_list; // Child_list.clone() ?
}

public addChild(Child c) {
Child_list.addElement(c);
}

public removeChild(Child c) {
Child_list.removeElement(c);
}

And then the Driver class could take options to
perform "deep" queries/updates/deletes taking into
account all children: populating parent objects when
they are creating/queried, saving out children objects
when parents are saved, and deleting children objects
when children are deleted.

This could probably even work with N:N relationships:
instead of containing lists of "children", each object
would just have a hash map containing references to
other objects to which it has an N:N relationship.

E.g.

private HashMap Associate_map = new HashMap();

public Iterator getAssociateList() {
return Associate_map.iterator();
}

etc.

Likewise, Driver methods could easily take this into
account, saving off associated rows.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.