DenTelezhkin/DTCollectionViewManager

Separate classes?

oks opened this issue · 1 comments

oks commented

Hello, I really like your extension, it's awesome!
But, do you think about separate controller and UIViewController classes. I think It will be better to encapsulate UICollectionView logic inside a NSObject-controller, and add it's as a property to your UIViewController. Because for example I use separate logic for views and controllers, using MVVM pattern, and this realisation sometimes is painfully for my architecture.
What do you think about this?

Hi there!

Historically, they were separated, but it added a lot of complexity to the project. There was a need to redirect UICollectionViewDelegate and UICollectionViewDatasource to UIViewController, and made some decisions, that basically should not be made by NSObject subclass.

In my experience, making use of container view controllers made an enormous difference for source code clarity. And it completely replaced MVVM for collection controllers, since their code is very short and clear. All collection controller should handle, is knowing about models, and reacting to user events. The presentation of cells and supplementary views is handled by UICollectionViewCell and UICollectionReusableView subclasses.

As for MVVM pattern - it is easily applicable, since you can just pass view model as a model for UICollectionViewCell.

Right now, i'm happy with the current implementation, but i always search for better and more clean solutions. If you have any particular problem with integrating my framework into your project, i would be happy to discuss it.