[Work Notes] Keep the interface small and clean

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

猜你喜欢

转载自blog.csdn.net/weixin_34010949/article/details/93492871
今日推荐