• JavaScript's dynamic nature enable very elegantly to have a sum of code compose of selectable components. For example, a UI (singleton) instance can be complemented / expanded with multiple methods and properties that are needed for a particular widget, for example, a button, or for a check box. If more sophisticated, the UI object acts as a factory with passing the widget class name as a string...

    In regard of overbloating: with limited resources, the conceptually clean, o-o, robust and flexible design has to be transformed into a resource adequate implementation design. It is nothing wrong to think o-o bloated but very clear. It is though a question whether the implementation should be the literal translation of the design. Furthermore, thinking in objects is always better than in functions. How an object is implemented though, may vary. Even though JSON is already terse compared to XML, it is still way bulkier than an array of values.

    Think of the array as a the static properties of the object with the index numbers mapping to variable names. the first value in the array can hold to the type (class) of the object and is used in the behavioral object (singleton) to pick the appropriate method - the method that goes with the particular array of values... This is not only the most compact way of saying things - especially in Espruino where the source is executed - but also the fastest in execution.


Avatar for allObjects @allObjects started