Get/Set/Add/Count in OM Classes
OM Classes generated from complex models are very bloated at the moment for several reasons:
For every field:
- get* Method
- set* method
For every referring foreign key:
- get* method
- set* method
- init* method
- add* method
- count* method
In 2.0 we could make more "lightweight objects". There could be two possibilities that need to be discussed:
- overloading the BaseObject via __call().
- IDEA: let all the methods in BaseOMClass, but merge each group (for example count*) to use some method in the BaseObject class. This methods would get their information as parameter - example:
BaseAuthorPeer->countBooks() calls BaseObject->count(table, field, fk) BaseAuthorPeer->getBooks() calls BaseObject->getFKEntries(table, field, fk) BaseAuthorPeer->addBook() calls BaseObject->addNMEntry(table, field, fk, baseobject $book)
Advantages of __call()
- mostly lightweight
- more compile speed (but irrelevant with bytecode cache)
Disadvantages of __call()
- no more code inspection in your IDE
- __call(), but at least call_user_func_array is known to be slow at runtime
- no clear `interface' of the class anymore
the middle way
- interface of the class and code inspection would be preserved
- no redundant generated code anymore
- no interceptor method needed
Questions
- __call() and static methods for peer classes?
- making decision what's the best way for getting more lightweight objects
