Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7312
  • 博文数量: 3
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 10
  • 用 户 组: 普通用户
  • 注册时间: 2020-02-26 12:14
文章分类
文章存档

2020年(3)

我的朋友
最近访客

分类: 系统运维

2020-02-26 12:35:29

原文地址:RPG IV编程风格建议 作者:Qian37

一、注释

a) 用注释说明代码

b) Program或者Procedure开头添加Summary

c) 用注释将代码分块

二、声明

a) 程序中用到的所有的变量都在D表声明

b) DS定义时使用缩进

c) DS定义时使用Length Notation而不要用Positional  Notation

三、命名惯例

a) 名字要有描述意义

b) 使用大小写区分单词分割

c) 尽量不使用特殊字符(@#$

四、指示器

a) 尽量少使用指示器,尽量使用Build-in函数,如%EOF,%ERROR,%FOUND

b) 尽量用EVAL *INXX = *ON/*OFF代替SETON/SETOFF

c) 给指示器加个注释。。。

五、结构化编程技术

a) 不使用GOTO, CABxx, COMP

b) 不使用过时的IFxx, DOUxx, DOWxx, WHxx操作符

c) 多分支逻辑用SELECT  WHEN OTHER ENDSL实现

d) ENDxx要成对出现

六、模块化编程技术

a) Use RPG IVs prototyping capabilities to define parameters and procedure interfaces

b) Store prototypes in /COPY members

c) Use IMPORT and EXPORT only for global data items

七、字符串操作

a) 尽量将字符串放在常量中而不是Array或者Table

b) 尽量避免使用ArrayDS去操作字符串

c) 尽可能的使用EVAL操作字符串

八、不要退化!!!

a) 不要在1-5填写序号

b) 不要使用program-described File

c) 不要使用过时的操作符

d) 如果Build-in函数提供某一操作符的功能,那么尽量使用Build-in函数

e) 尽量使用CALLP来代替CALLCALLB

九、其他

a) 在所有表中使用Keyword时尽量分行,一个Keyword写一行

十、建议

a) Make it right before you make it faster.

b) Keep it right when you make it faster.

c) Make it clear before you make it faster.

d) Do not sacrifice clarity for small gains in efficiency.





参考A Sorcerer’s Guide to System Access and More.pdf

Chapter 2. Programming RPG IV with style

阅读(832) | 评论(0) | 转发(0) |
0

上一篇:如何在bacth job中调试RPG Program?

下一篇:没有了

给主人留下些什么吧!~~