[Work Notes] Keep the interface small and clean

文章讲述在审查缺陷修复时,回顾了CanvasRow提供的GetExistingCell和GetCell两个方法。二者区别在于GetCell有按需创建逻辑,编码时易混淆。经讨论,决定将其合并为一个方法CanvasCell GetCell(int nColumnID, bool OnDemandCreate = false),以保持接口简洁,避免误解。

Today, Peak and I reviewed two methods provided by CanvasRow when we review a defect fixing:

  1. GetExistingCell(int nColumnID)

    As its name indicates it search all the existing cells with the specified nColumnID. And it will return null if no existing cell.

  2. GetCell(int nColumnID)

    It will call GetExistingCell firstly, and if it get nothing, it will constructor a new CanvasCell as the result.

 

As you can see, the different between them is the GetCell has the On-Demand-Creation logic. But when we are coding, we don’t notice the different between them, in the scenario of the defect, we should call GetExistingCell, but will call

GetCell. The big problem for me is that some new CanvasCells are introduced, but it is not needed.

 

After some discussing, we realized that we only need one method:

   CanvasCell GetCell(int nColumnID, bool OnDemandCreate = false);

By this way, we have keeping the interface small and clean to avoid the missing understanding.

转载于:https://www.cnblogs.com/jalenwang/archive/2012/01/06/2315226.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值