agentscript0 icon indicating copy to clipboard operation
agentscript0 copied to clipboard

Expand Options Object to Simplify Configuration

Open backspaces opened this issue 10 years ago • 4 comments

When the constructor argument list for class Model got too huge (thanks Benny!) we wisely converted it to an options objects with readable key/value pairs.

While experimenting with performance and configuration, we added odd API's like "useSprites" and MultiModel configuration. We also have models with no Links, for example, and it would be more light-weight to simply remove that canvas and its associated Link and Links classes.

So this recommendation is to create a configuration option that is the input to Model that includes all these configuration details.

It should start out defaulted to reasonable values and be over-written by the programmer's preferences. It may need a small amount of code, as well as being self documenting. Console print like a "-help" flag maybe. It also should allow user/developer/plugins to augment it, i.e. "add" new options.

As we rid ourselves of the older ad-hoc configuration functions, they will be replaced with a deprecation message. This it is only "semi-breaking".

backspaces avatar Feb 15 '15 19:02 backspaces

So this would be a config object nested in the options object?

mariusnita avatar Feb 18 '15 15:02 mariusnita

If I read you correctly, yes.

I'm thinking it would be a small class to help a bit. It would be a strict extension of the current Module constructor initialization object: {minX: -10, maxX:10, ...} with sub-objects for each "layer" so there'd be an entry per "breed" with its defaults: {..., agents: {shape: "Arrow", size: 2.5, color: "green", useSprites: true, ...}, ...}

It would not force use of these defaults, only clean up and centralize them. There would still be a dynamic way to do this: agents.setDefault(...)

When I mention a "small class" to help, I'm thinking of being able to specify the patch world by height/width rather than minX,maxX.. etc but I'm not sure about this. Start small and see how it goes.

backspaces avatar Feb 18 '15 16:02 backspaces

Cool! This might help us think about sensical defaults and what we want to modularize, too.

bennlich avatar Feb 19 '15 22:02 bennlich

Yup, that's the idea .. just not sure how far to take it. Lots of github projects take this approach especially with npm based projects.

backspaces avatar Feb 19 '15 23:02 backspaces