Skip to content

ObjectCreator is uglyyyy. #19

@lukaspj

Description

@lukaspj

I really wanna clean up object creation.

new A() { new B(){}; };

Is just syntactic sugar for:

new A() {};
new B() {};
A.add(B);

So instead of this:

            oc_Newobject4["#Newobject1"] = oc_Newobject1;

We could have this:

SimSet set = oc_Newobject4.create();
set.add(oc_Newobject1.create());

And we should use named parameters in the constructors so that instead of this:

ObjectCreator oc_Newobject4 = new ObjectCreator("GuiWindowCtrl", "ConsoleDlgWindow", typeof (ConsoleDlgWindow));
            oc_Newobject4["isContainer"] = "1";
            oc_Newobject4["AllowPopWindow"] = "1";

We should have:

// Have to have GuiWindowCtrl constructor in a seperate class to avoid boilerplate constructors in 
// classes derived from GuiWindowCtrl.
GuiWindowCtrl oc_Newobject4 = new GuiWindowCtrlInstance(name: "ConsoleDlgWindow", isContainer: true, AllowPopWindow: true);

// Alternately
GuiWindowCtrl oc_Newobject4 = (new GuiWindowCtrlInstance("ConsoleDlgWindow")
{
  isContainer = true,
  AllowPopWindow = true
}).create();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions