Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

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.