Home Comments

Source Code Generator Option for Constructors

plissakplissak Member Paul LissakOrganization: Sky RoadProject: Analytic Services
The slice2java and slice2cs source code generators create two constructors for each Slice class definition. One constructor takes no arguments while the other takes all the member variables. This isn't a problem for C#, but Java has a limit of 255 arguments in a constructor. I recommend adding an option to the source code generators to eliminate the generation of constructors that take all the member variables.

Granted it is unlikely that you'll encounter a class definition with more than 255 member variables. Usually the classes are normalized into something more manageable. However I am working with an analytical model and those tend to be less object oriented. This model takes in over 300 parameters. My goal was to keep the Slice definitions as similar as possible to the model parameters.

It seems like these constructors are there for only for convenience. So the generated code should work fine without the all member variable constructors.

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Paul,

    Welcome to the forum.

    Thanks for bringing this to our attention. I'm not sure that an option to disable the "one-shot" constructors would be generally useful enough to warrant adding to the translator, but we definitely should not generate uncompilable code. We'll get this fixed for the next release.

    Regards,
    Mark
Sign In or Register to comment.