A very common issue which many of you also have faced in SAPUI5 developments, specially people who are using javascript view to design the UI5 front end.
Important question arises before starting with SAPUI5 application developments, whether to use XML views or JavaScript views. Here are some points I would like to share which you can go through and think to decide upon.
Mostly XML views are used in SAPUI5 developments rather than JavaScript views because:
- To protect MVC (Model-View-Controller) guidelines: If a developer uses JavaScript views, then there is chance of putting processing code in the view itself, which violates the MVC principle.
- As XML is not a programming language, there is no way you can put processing logic inside XML views. So, in that case, you will always use controller to put your processing logic following MVC architecture.
- XML is the industry standard to put views in a UI based application.
- The SAP Web IDE includes a WYSIWYG(What you see is what you get) graphical layout editor that works only with XML views.
- Using XML views, you can use Layout Editor means Editor that allows you to easily drag and drop UI controls on the screen/page and it's ready-made code will get available automatically to you.
- Parsing of XML in devices is faster than JavaScript.
- XML views are more attractive when compared to JS based view.
- SAP ships all Fiori apps using XML views. So, as a SAPUI5 developer, better to have atleast the knowledge in how to read XML based views also along with JS views.
- SAP recommendation is to use XML views instead of JS, as it is better in terms of maintainability and readability.
- You can easily find out the structure and hierarchy of UI controls that are laid out within each other.
MVC architecture:
Everything has its own advantage and disadvantages, you may find those points for both type of views, but it's in the developer's hand to decide whichever he/she finds more comfortable.
The main advantage of using XML view is its compatibility to be processed by all the platforms, devices and programming languages.
Moreover, the beauty of XML view is SAPUI5 libraries like sap.ui.core, sap.ui.commons etc. mentioned in a namespace gets loaded by the view itself.(But usually we put those libraries in a Bootstrap code inside index.html).
THINK! and DECIDE! or Just Give it a TRY!
🙂
Be open for new things!!