The Art of Readable Code

Chapter One:

key idea:

Code should be written to minimize the time it would take for someone else to understand it.

Chapter Two:

key idea:

pack information into your names.

a few tips:

Use specific words-- for example, instead of Get, would like Fetch or Download might be better, depending on the content.

Avoid generic names like tmp and retval, unless there's a specific reason to use them.

Use concrete names that describe things in more detail -- the name ServerCanStart is vague compare to CanListenPort.

Attach important details to variable  names-- for example append _ms to a variable whose value is in milliseconds or  prepend raw_ to an unprocessed variable that need escaping.

Use longer names for large scopes--don't use cryptic one- or two-letter names for variable that span multiple screens; short names are better for variables that span only a few lines.

Use capitalization, underscores, and so on in a meaningful way--for example, you can apprend "_" to class members to distinguish them from local variables



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值