[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.

posted on 2012-01-06 22:22  Jalen Wang  阅读(904)  评论(0编辑  收藏  举报

导航