cancel
Showing results for 
Search instead for 
Did you mean: 

Interfaces, Classes and Base Classes, HowTo OOP

Former Member
0 Kudos

Hi there

I want to do some interface implementation and afterwards creating some classes extending the interfaces.

I took a look at the custom controls developer guide, but this guide is for UI controls only. I want to do some kind of database abstraction layer, with some interface methods and some implementing classes.

What is the right way to do this?

  1. Define some interfaces, extending the interfaces by using sap.ui.base.Object.extend?
  2. Don't use interfaces at all. Simply use sap.ui.base.Object.extend?
  3. Don't use Object as a base class, but use sap.ui.base.ManagedObject.extend instead?

The main goal of these abstract classes is to provide some methods and maybe some sample implementation (or some kind of comments, if not possible at all). Later these methods will get implemented by another classes using these interfaces.

The developer guide doesn't get that much hints on how to use object oriented programming using SAPUI5.

Currently I'm on SAPUI5 1.16.3 using NetWeaver AS Java.

Tobias

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

After searching a lot I am using the ManagedObject. However, there are some issues when using ManagedObject.

For controls, use Control.extend, and for everything else, most people will use Object.extend.

Former Member
0 Kudos


Hi,

did you manage to use an Java-like paradigma?

in example:


TestObjectClass = function(){ };

TestObjectClass.protottype = sap.ui.base.Object.extend("TestObjectClass", {

    constructor: function() {

                    alert("TestObjectClass-Const");

    }

});

TestObjectClass.prototype.doIt = function(){

alert("DoIT");

};

TestObjectClassNeu = function (){ };

TestObjectClassNeu.prototype = TestObjectClass.extend("TestObjectClassNeu", {

    constructor : function(){

              alert("TestObjectClassNeu-COnst");

    },

    doIt : function(){

              alert("DoIT-Now!");

    }

});

When you want to try use:


var oInstance = new TestObjectClassNeu();

oInstance.doIt();

If i want to use something like this in the function doIt, but it won't work:


TestObjectClassNeu.prototype.doIt = function(){

          super();

          alert("DoIt-Now");

};

Did you find a solution for that?

Former Member
0 Kudos

found the answer...

look into thread

Former Member
0 Kudos

Most of the time I'm using Object.extend, for entity classes I use ManagedObject.extend.

For all other tasks I simply define some moduls using jQuery.sap.declare().

Answers (0)