joshaber Josh Abernathy
Monolithic protocols like UITableViewDataSource/Delegate suck because they limit the ability to abstract away smaller pieces.

January 30, 2013 #

rob_rix Rob Rix
@joshaber The pragmatism argument for this always annoys me. “When is anyone going to want that?” If you do your job right, they will.

January 30, 2013 #

optshiftk Kyle S.
@rob_rix @joshaber Having implemented it both ways, the API designed is doing both of you a favor by making it a monolithic protocol.

January 30, 2013 #

joshaber Josh Abernathy
@optshiftk @rob_rix why?

January 30, 2013 #

optshiftk Kyle S.
@joshaber @rob_rix Because otherwise you write a ton of glue code trying to synchronize state between various objects.

January 30, 2013 #

rob_rix Rob Rix
@optshiftk @joshaber Your client doesn’t have to use all the flexibility available. Each delegate can be the same object…

January 30, 2013 #

optshiftk Kyle S.
@rob_rix @joshaber If the most commonly correct use case is to have them be the same object, the API designer should encourage that.

January 30, 2013 #

rob_rix Rob Rix
@optshiftk @joshaber Then have a bulk delegate setter or something. Bad factoring is still bad factoring when it’s convenient :\

January 30, 2013 #

optshiftk Kyle S.
@rob_rix @joshaber It's not a bad factoring. It's a factoring you happen to disagree with, but I believe it results in better code.

January 30, 2013 #

rob_rix Rob Rix
@optshiftk @joshaber I guess I’m arguing that if they’re really separate concerns they should be separate API…

January 30, 2013 #

optshiftk Kyle S.
@rob_rix @joshaber In our NSOutlineView equivalent, we actually replaced our data source protocol with a required controller object.

January 30, 2013 #

rob_rix Rob Rix
@optshiftk @joshaber …and that cell layout/display/content/etc are separate concerns.

January 30, 2013 #

rob_rix Rob Rix
@optshiftk @joshaber I think UICollectionView gets this more right with the layout objects, for example.

January 30, 2013 #

optshiftk Kyle S.
@rob_rix @joshaber Yes, that's the spirit of our controller object. "Your data is presented in a tree; give us a tree controller."

January 30, 2013 #

schwa Jonathan Wight
@rob_rix @optshiftk @joshaber did you just say “bulk delegate setter”? Oh boy.

January 30, 2013 #

rob_rix Rob Rix
@schwa @optshiftk @joshaber I didn’t say I liked the idea :P

January 30, 2013 #

tomcatterall Thomas Catterall
@rob_rix @schwa @optshiftk @joshaber I tried so damn hard to factor out a Datasource in anticipation of a change of data persistence.

January 30, 2013 #

tomcatterall Thomas Catterall
@rob_rix @schwa @optshiftk @joshaber def not worth it.

January 30, 2013 #

optshiftk Kyle S.
@rob_rix @joshaber Otherwise the support for different objects won't be wel-tested, and the implementation more fragile for no gain.

January 30, 2013 #

rob_rix Rob Rix
@optshiftk @joshaber I also feel like this is an argument for the things doing the delegating to be better-factored, of course.

January 30, 2013 #

jimcorreia Jim Correia
@rob_rix That’s the way WebKit works. It always feels like a PITA. I don’t think I’ve ever split the delegates.

January 30, 2013 #

rob_rix Rob Rix
@joshaber It also falls to API designers to encourage good design on the part of their clients.

January 30, 2013 #

joshaber Josh Abernathy
@rob_rix Yep, unfortunately it often feels like designs push us towards minimal reuse and monolithic classes :(

January 30, 2013 #

rob_rix Rob Rix
@joshaber it definitely encourages UIViewController Subclasses As The Engine Of Application State, yes :\

January 30, 2013 #

andy_matuschak Andy Matuschak
@rob_rix @joshaber Infinite :(

January 30, 2013 #

mrjjwright John Wright
@joshaber What is an e.g. of a smaller piece you want control over?

January 30, 2013 #

joshaber Josh Abernathy
@mrjjwright UITableViewDelegate contains selection, variable height, footers, editing, etc.

January 30, 2013 #

drance Matt Drance
@joshaber The irony, though, is that it is two monoliths. As opposed to one.

January 30, 2013 #

joshaber Josh Abernathy
@drance It kinda feels like they started well-factored and then just threw everything new in Delegate

January 30, 2013 #

drance Matt Drance
@joshaber Completely agree that the display methods should be separate. I’ve punted those to class methods in the cell when coupling is low.

January 30, 2013 #