on 2020 May 01 1:27 PM
Hi All,
In my custom application development, i have a controller with having more than 1000+ lines of code. I want to separate and put certain logic/implementation from my main controller. Especially the service call, value help implementation etc.
Approach i followed:
I created new control(example ServiceCall.js) and imported the ServiceCall.js in my parent controller.
New Control File: ServcieCall.js:
sap.ui.define([
"./BaseController",
"sap/m/MessageToast"
], function (BaseController, MessageToast) {
"use strict";
var confirmationDialog;
var oData;
var i18nModel;
/**
* ServiceCall.js is a control file which is used to sepereate the Creation logic from
* the MainController.
*/
return {
callCreateGroupFragment: function (oCoreControl, that, sParameter) {
}
};
});
Define and implemented the required methods inside the ServiceCall.js.
Then in my parent controller, i just called the ServiceCall control method just using ServiceCall.methodname(arguments).
CreateGroup.callCreateGroupFragment(oCoreControl, this, "actual");
Is this a right way to do or what could be the best way to do this kind of implementation?
Thank you,
Regards,
JK.
Request clarification before answering.
I had the same problem with UI5 in the past and came up with the following:
https://blogs.sap.com/2019/12/27/ui5-advanced-programming-model-overview-ui5con-2019/
Enjoy reading and please share your opinion!
Most of the files are not larger than 200 lines but this can be different depending on the project and everything is clearly and understandable separated. Hoot helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks c3d1947136cd4c748a7aa794001af496 , yes i referred some of your blog related to handle is MVC effectively. Thanks for your view on this. Bu in my question, i stated that they way i called the js file,without instantiating Directly, is that right?
Or Should i need to go for ManagedObject extend or Object extend.
Regards,
JK.
Without instantiating can be helpful in case you need to extend it later.
I would definitely go for extend on ManagedObject or Object. I used Object because it can be used in a more generic way. In the ManagedObject, you need to define the parameters upfront.
firstly, appreciate that you are attempting to modularize the code. But be also careful of loading multiple files compared to single file. With component-preload file loading of files is improved so go for decoupling only when it makes clear benefit especially in terms of reuse or maintenance.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
21 | |
8 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.