0

I have seen people are using prefix o a lot when developing ui5 application.

var oRowsModel = new sap.ui.model.json.JSONModel();
    oValueHelpDialog.getTable().setModel(oRowsModel);
   if (oValueHelpDialog.getTable().bindRows){
    oValueHelpDialog.getTable().bindRows("/"); 
}

this.getView().setModel(oModel);

var oSelectedItem = oEvent.getParameter("selectedItem"),
            oTimeline = this.getView().byId("ActivityTimeline"),
            oTimelineBinding = oTimeline.getBinding("content");

Does it help somehow ? Is it a best practice ? What is the advantage?

I think that a lot of things are objects and specifying o does not help much. Why then to use it?

Ant
  • 115
  • 6
  • Naming preference most likely. Have you read their API docs? It might explain the naming scheme. – evolutionxbox Mar 30 '17 at 14:48
  • 2
    SAP [recommend Hungarian Notation](https://help.sap.com/saphelp_scm700_ehp03/helpdata/en/ed/ed636b85584cd586b1fe231d2b5dac/content.htm) - if this is a good thing or a bad thing is completely subjective. – Alex K. Mar 30 '17 at 14:51
  • Yes they have it everywhere in API docs. For example : attachDataStateChange(fnFunction, oListener?) – Ant Mar 30 '17 at 14:53
  • [In short, Hungarian Notation where you prefix your variable names with their type (string) (Systems Hungarian) is bad because it's useless.](http://stackoverflow.com/questions/111933/why-shouldnt-i-use-hungarian-notation). – Ant Mar 30 '17 at 15:01
  • It means its an 'Object'. As @Ant mentioned, this is according to the Hungarian Notation. That is the reason you will see string start with 's' like sPath. So, basically all our controls are classes, and we create an instance ( object) using 'new' keyword. Hence, the 'o' for object. Using this one can easily use the method available on strings, arrays, objects etc. Makes code maintainance a lot more easier. – Rahul Bhardwaj Mar 30 '17 at 15:54

3 Answers3

1

The prefixing of variables is just a naming convention carried over from the native SAP programming language called ABAP. In ABAP it is a long standing convention to prefix variables so that one can tell the type of the variable and if the variable is local or global, for instance lv_myvar for a local variable, and gt_mytab for a table type that is global. There is really no particular reason to continue with this practice in Javascript and UI5 - if you don´t like, don´t do it.

Frank
  • 56
  • 4
0

o for Object maybe? :)

Plus it makes sense, to append an 'o' to your variable name,as you shall be fiddling around with objects all the time.

Plus, it helps much to use oList instead of List, as it is a control.

Dibya Ranjan
  • 80
  • 3
  • 18
0

o means object. You can see here

MakifYcl
  • 41
  • 2