So I recently worked on extending the functionality of the List/Details app pattern: implementing a swipe on the Details view to move to the previous or next item in the parent list.
My solution requires adding one property to the Details view, 3 properties to the List view, implementing several new functions in each, and ensuring that some code gets run in the ViewDidLoad of both, and the DidSelect method of the table view.
I have been looking over the obvious mechanisms available in Cocoa and XCode 4 for re-use (snippets, subclassing and categories) in order to make this code (which is pretty much stand-alone) easier to add into other screens and apps and none seem suited for it. I can't figure out any mechanism that could encapsulate all of the needed changes, or simplify code re-use for other screens or projects.
Here are specific short comings:
Snippets: can only insert a single block of code, so isn't suited for code that requires changes in multiple files, or even multiple points in the same file.
Categories: can add new methods (or redefine existing methods) but can't add new properties.
Subclassing: can add new methods and properties, but doesn't address changes across multiple classes to implement a solution.
A hybrid approach (using snippets, categories and subclassing) could be used, but there is no mechanism to package such code modifications together!
Even if they are from other languages or IDEs, it would be interesting to know of any approaches used elsewhere.
Thanks