I was doing research on writing modular clean code while working with UITableView & UICollectionView and I found nice blog on writing lighter ViewControllers by Objc.io. While following practices given by author I came up with a paragraph which says about Same Cell type and Multiple Model Object not in detail, just descriptive. I just wanted to ask does anyone suggest how we could achieve this in better more modular way? The paragraph says something like this,
In cases where we have multiple model objects that can be presented using the same cell type, we can even go one step further to gain reusability of the cell. First, we define a protocol on the cell to which an object must conform in order to be displayed by this cell type. Then we simply change the configure method in the cell category to accept any object conforming to this protocol. These simple steps decouple the cell from any specific model object and make it applicable to different data types.
Can anyone explain what it meant? I know it is off topic but it may help someone writing better code.
Aucun commentaire:
Enregistrer un commentaire