Skip to Content
Author's profile photo Former Member

UI5 measure api design concerns

When I go throw, there is PerfMeasurement class implementation. I am afraid there are two concerns in my mind.

Firstly there are two different patterns to implement a class, one is prototype pattern, such as Version:

function Version() {}
Version.prototype.InRange() {}

The another pattern is constructor. Such as PerfMeasurement.

function PerfMeasurement() {
     this._start = function() {};
     this.start = this['_start'];

According to _start function name, it should be a private function. But we could access this private function.

> function (sId, sInfo, aCategories) {
                if (!bActive) {
                aCategories = checkCategories(aCategories);
                if (!aCategories) {
                var iTime =…

Since private and public functions are defined in the same function scope, then private function could get function instance reference this, and public functions could access private functions. For example:

var JsClass = function(name) {
    var that = this; = name;
    function _sayHello() {
    this.say = function() {
var instanceOfJsClass = new JsClass('Mike');
instanceOfJsClass.say();              // Access public function
instanceofJsClass._sayHello();     // Can't access private function

In the same way, _start could be removed bind from function instance reference this. And then _start function become a real private function, and the same time it could be accessed by other public functions.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.