m1 icon indicating copy to clipboard operation
m1 copied to clipboard

Enhancement: widget.render should dynamically call function

Open azaroth42 opened this issue 11 years ago • 1 comments

Instead of a switch, the render() function should determine which function to call by dynamically constructing the name from the object's type. This would allow future widget types not to have to change the base render function.

Along the lines of

var fn = "render" + this.type[0].toUpperCase() + this.type.substring(1,100);
if (this[fn]) {
  this[fn]();
} else {
  // raise NotImplementedError() ?
}

azaroth42 avatar Dec 18 '13 20:12 azaroth42

This is a good observation and reflects the general spirit of all the areas the project might need refactoring in the future. When there were relatively few options and we were still building out the front-facing features, it was more efficacious to begin with one case, then include a second, etc, but there are likely several regions of the codebase which could now benefit from a higher level of abstraction with error handling. Identifying these in a compendious manner would be a great help.

aeschylus avatar Dec 18 '13 21:12 aeschylus