SAP UI5 CRM Reuse Fiori应用 note.js代码审查结果

简介: SAP UI5 CRM Reuse Fiori应用 note.js代码审查结果

目录

image.png


image.png


image.png


1. Unused require statement

Line4 could be deleted.


image.png


2. Unused code _dateBound = true

Is this _dateBound really still needed? Is it previously introduced for lifecycle issue solution?


image.png


Comment by Jerry on 2015-01-23 17:00PM OK I am wrong.


image.png


3. Robustness of sap.cus.crm.lib.reuse.controls.Note.prototype.setModel

It is better not to make any assumptions that the consumer will call this method setModel as we expected.

Is there any possibility that all the internal reference like _noteTypeItemTemplate is still not initialized.

In this case, the method execution will cause javascript error.


image.png


4. This.getModel() VS model

Why not use model.getProperty directly? I have verified in debugger, there are exactly the same reference?


image.png


5. Naming convention

We can not judge the real content contained in these two variables at a first glance – A little confused about the meaning of noteType and _noteType.


image.png


Is it possible to add more information inline to variable _noteType, for example change _noteType

To _oNoteTypeSelect, so that the one who reads the source code could immediately know it is a reference for select control?


6. Not necessary to loop the whole data set every time to get language description

It is possible to have an inner buffer and every time we first try if the corresponding language description is already in inner buffer already:


image.png



Another example is setAggregation implementation by ui5 framework:

Get:


image.png


Set:


image.png


This logic is widely used in ui5 framework:


image.png


7. Unnecessary variable isDefault

Previously I assume there is some logic on isDefault like if ( XXX ) { isDefault = true } else { isDefault = false }


But actually it is not. Why not directly pass a true in line 51?


image.png


8. Define constant

Can we define some “constant” in init method to avoid resourceBundle call repeatedly?

For example, in init method,

Var EDIT_NOTE_DIALOG_TITLE = this.oResourceBundle.getText(“EDIT_NOTE_DIALOG_TITLE”);


image.png


9. Unnecessary variable


image.png

Use return new sap.ui.model.json.JSONModel(oData) instead. Comment by Jerry on 2015-01-23 17:15PM

Not necessary to change: 因为发现UI5的框架代码也这样用的:


image.png


10. Nested if

A little bit ugly, can we use the following one?


image.png


11. Is jQuery.proxy really necessary?

Haven’t yet measured the overhead of jQuery.proxy.


image.png


Some open source framework just use the following approach to avoid the additional jQuery.proxy call:


image.png


Also our own ui5 framework implementation:

doSo


image.png


image.png


12. Magic number

Can we use “constant” to avoid this magic number?


image.png


13. Better variable name?

After I go through the whole source code, I get to know that for note creation and edit case, we use the same

dialog instance, right? So _noteCreateDialog could be used both for create and Edit case?

In that case, it is better to rename _noteCreateDialog as _noteOperationDialog?


image.png


In the code below, it may confuse reader that the _getDialog can only construct Dialog for creation purpose.


image.png


image.png


14. Inconsistent naming convention

Sometimes we use prefix o to indicate the variable has object type, sometimes not, e.g noteCreateDialog.


image.png


15. Better method name

The below method assembles and finally return a model for given purpose – note creation and update.


image.png

Normally, we have two styles below:

image.png

So better name like getCalculatedModel4AddNoteDialog.

Comment by Jerry on 2015-01-23 17:14PM

Just see a similar usage as ours in JSONModel,js …. , so not necessary to change?



相关文章
|
13天前
|
Linux C++ Windows
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
【Azure 应用服务】Azure App Service(Windows)环境中如何让.NET应用调用SAP NetWeaver RFC函数
|
6天前
|
vr&ar C# 图形学
WPF与AR/VR的激情碰撞:解锁Windows Presentation Foundation应用新维度,探索增强现实与虚拟现实技术在现代UI设计中的无限可能与实战应用详解
【8月更文挑战第31天】增强现实(AR)与虚拟现实(VR)技术正迅速改变生活和工作方式,在游戏、教育及工业等领域展现出广泛应用前景。本文探讨如何在Windows Presentation Foundation(WPF)环境中实现AR/VR功能,通过具体示例代码展示整合过程。尽管WPF本身不直接支持AR/VR,但借助第三方库如Unity、Vuforia或OpenVR,可实现沉浸式体验。例如,通过Unity和Vuforia在WPF中创建AR应用,或利用OpenVR在WPF中集成VR功能,从而提升用户体验并拓展应用功能边界。
17 0
|
6天前
|
C# 开发者 设计模式
WPF开发者必读:命令模式应用秘籍,轻松简化UI与业务逻辑交互,让你的代码更上一层楼!
【8月更文挑战第31天】在WPF应用开发中,命令模式是简化UI与业务逻辑交互的关键技术,通过将请求封装为对象,实现UI操作与业务逻辑分离,便于代码维护与扩展。本文介绍命令模式的概念及实现方法,包括使用`ICommand`接口、`RelayCommand`类及自定义命令等方式,并提供示例代码展示如何在项目中应用命令模式。
14 0
|
6天前
|
开发者 Android开发 UED
打造流畅应用:深入探索如何在Xamarin项目中选择并实现最佳UI/UX设计的实践指南
【8月更文挑战第31天】在数字化时代,UI/UX设计成为应用成功的关键。Xamarin以高效开发和强大兼容性著称,其设计理念“一次编写,处处运行”需充分适应多平台特性,提供一致体验。选择Xamarin.Forms或结合Xamarin.Native可实现跨平台UI设计;遵循各平台设计指南,保持布局一致性和简洁性;通过用户测试不断优化。最终,结合技术和用户需求,打造美观实用的应用,脱颖而出。
17 0
|
24天前
数字化核心构建问题之SAP为应用软件扎根客户打基础如何解决
数字化核心构建问题之SAP为应用软件扎根客户打基础如何解决
10 0
|
4月前
|
前端开发 搜索推荐 UED
【Flutter前端技术开发专栏】Flutter中的高级UI组件应用
【4月更文挑战第30天】探索Flutter的高级UI组件,如`TabBar`、`Drawer`、`BottomSheet`,提升应用体验和美观度。使用高级组件能节省开发时间,提供内置交互逻辑和优秀视觉效果。示例代码展示了如何实现底部导航栏、侧边导航和底部弹出菜单。同时,自定义组件允许个性化设计和功能扩展,但也带来性能优化和维护挑战。参考Flutter官方文档和教程,深入学习并有效利用这些组件。
115 0
【Flutter前端技术开发专栏】Flutter中的高级UI组件应用
|
4月前
|
JavaScript 前端开发
试读版:如何找出 SAP 标准 Fiori 应用某个按钮点击后执行的 JavaScript 源代码
试读版:如何找出 SAP 标准 Fiori 应用某个按钮点击后执行的 JavaScript 源代码
|
4月前
|
监控 搜索推荐 安全
SAP Commerce Cloud Context Driven Services 里 profile-tag.js 的作用介绍
SAP Commerce Cloud Context Driven Services 里 profile-tag.js 的作用介绍
|
4月前
|
前端开发 搜索推荐 开发者
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
|
4月前
|
JavaScript 前端开发 开发者
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
下一篇
DDNS