QmlWeb/Qml.js/Design Questions and Decisions: Difference between revisions

From KDE Community Wiki
< QmlWeb‎ | Qml.js
(Created page with "This page intends to collect questions about software architecute and software design, pros and cons as well as the decisions made on the topic. ==Runtime Architecture== ===G...")
 
No edit summary
Line 16: Line 16:
* nice while debugging
* nice while debugging
* worse performance in IE
* worse performance in IE
* you can't use object literals and inheritance at the same time in a standard compliant manner




Benchmark: http://jsperf.com/getter-setter/7
Benchmark: http://jsperf.com/getter-setter/7


'''Decision:''' Use transparent getter/setter using lieral notation.
'''Decision:''' Use C++ style getters and setters
 
=== Storing properties ===
As we're using setters and getters in either way, we need to store the actual property value separated. There're multiple possibilities for that:
; Private member using closures
; Private member using like _width
; Using property objects and direct object references
; Using property indexes and a properties array
; Using a properties object and access it per name

Revision as of 08:34, 4 March 2015

This page intends to collect questions about software architecute and software design, pros and cons as well as the decisions made on the topic.

Runtime Architecture

Getter/Setter Technique

Possibilities:

C++ style getters and setters
this.width(); and this.setWidth(width);
  • C++ style
  • fast in all browsers
Transparent getter/setter using Object.defineProperty
Object.defineProperty(this, "width", { get function(){}, set: function(){} });
  • nice while debugging
  • worse performance in IE
  • horrible performance in Firefox
Transparent getter/setter using literal notation
  • nice while debugging
  • worse performance in IE
  • you can't use object literals and inheritance at the same time in a standard compliant manner


Benchmark: http://jsperf.com/getter-setter/7

Decision: Use C++ style getters and setters

Storing properties

As we're using setters and getters in either way, we need to store the actual property value separated. There're multiple possibilities for that:

Private member using closures
Private member using like _width
Using property objects and direct object references
Using property indexes and a properties array
Using a properties object and access it per name