class mapping E7 & E8: Add parameter(s) to the generated constructors to allow efficient object creation & Allow nested object serialization use the E7 constructors when appropriate

View: New views
1 Messages — Rating Filter:   Alert me  

class mapping E7 & E8: Add parameter(s) to the generated constructors to allow efficient object creation & Allow nested object serialization use the E7 constructors when appropriate

by mikewse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here I'm starting a mail thread for two suggestions from Joe. I have put them in the same thread as they are two parts of the same feature. I have written some text on how I interpret the suggestions (Joe: please add/correct if needed).
 
[E7] Add parameter(s) to the generated constructors to allow efficient object creation
 
Example of generated mapped class with constructor parameters:
if (typeof MyClass != 'function') { 
   
function MyClass( field1, field2 ) {
        if ( arguments.length == 0 ) {
            this.field1 = <default value for type>;
            this.field2 = <default value for type>;
        }
        else if ( arguments.length == 2 ) {
            this.field1 = field1;
            this.field2 = field2;
        }
        else {
            throw new Error( "Wrong number of constructor arguments" );
        }
    }
}
 
[E8] Allow nested object serialization use the E7 constructors when appropriate
This would mean implementing the server-side code that use the constructors in DWRP:
s101=new MyClass(["bla",17],true)
 
Is this correct?
Comments?
 
Best regards
Mike
LightInTheBox - Buy quality products at wholesale price