养成良好编程习惯--编程规范

编程规范

1 格式规范,新的语句段落需要缩进,层次分明,整体结构应美观大方。如

    for (int i = 0; i < numscans; i++)
            {
                int y1 = (i * iHeight) / numscans;
                int y2 = ((i + 1) * iHeight) / numscans;
                if (QuickScan)
                    y2 = Math.Min(y2, y1 + DEFAULTSTRIPWIDTH);
                string sCodesRead = ReadBarcodes(bmp, y1, y2, direction, types);

                if ((sCodesRead != null) && (sCodesRead.Length > 0))
                {
                    string[] asCodes = sCodesRead.Split('|');
                    foreach (string sCode in asCodes)
                    {
                        if (!CodesRead.Contains(sCode))
                            CodesRead.Add(sCode);
                    }

                    break;
                }
            }

2 变量名,不可以用单纯的a,b,c,变量名应该和用途相结合,见名知意。

    如max表示最大值,min表示最小值,maxX和maxY表示取得最大值的X和Y坐标,m_width和m_height表示图像的高度和宽度,col表示图像列方向上的系数。

int max=0,min=256;

int maxX=0,maxY=0;

int m_width=lpbi->biwidth;

for(col=0;col<=window;col++){}

3 变量名后要加注释,以表示其用途。如

BYTE *m_buf;  //原始图像缓存

BYTE *afterFileter_buf;  //去除噪声后的图像缓存

 

4 函数需要加注释,以表明其用途,注释格式如下,详细说明函数功能,参数含义,返回数字及作者等

//funciton: Turns an 8 bits gray scale to 2bits gray scal

/warning: Only the 8 bits gray scale image with 2 values (0 and 255) will be correctly turned!

//pDib:Points to the image 's DIB contains BITMAPINFOHEADER, PALETTE and pixels

//return: New pointer to new DIB if sucess, null if failed.

//author: lulu

void * WINAPI EightBitsGrayToTwoBits(void * pDib)

{

}

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值