block by vijithassar 9e5348184bd183fd1597556ef44f5fc4

batch configuration methods

Full Screen

Since Mike originally intended the reusable chart pattern as a straw man proposal for further refinement, here’s a simple extension which I’ve found helpful on some recent projects. In addition to the configuration methods, a single multiple-input wrapper method can be defined (it’s called .set() in this example) which can then be used to run other individual configuration methods based on an input hashmap which specifies method names and arguments as keys and values. Here, it’s used to safely run methods which set size and position attributes for circles and squares which have slight semantic differences (r/cx/cy vs height/width/x/y, respectively) without needing to know which shape it’s operating on. This small addition allows for the flexibility and syntactic clarity of the individual methods while also retaining the option for fast one-shot configurations based on a single object.