m1
m1 copied to clipboard
Enhancement: widget.render should dynamically call function
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() ?
}
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.