Hacker News new | past | comments | ask | show | jobs | submit login

Here's hoping they have a piece on Swizzling!



This sounds like a maintenance programmers worst nightmare. Although I'm coming from a Java background so naturally I have accrued an unhealthy amount of bias.

Anybody from the more dynamic languages have any war stories about debugging/maintaining this sort of thing?


You must use it really, really, really sparingly. There are cases where it's useful, but they're pretty rare. When you do it, you need to document the crap out of it.

I've been lucky never to hit any code where someone did this kind of thing without taking that into consideration, so I can't say how bad it gets when it's screwed up. Used sparingly it can be pretty nice, but you have to be really sure you're not just overcomplicating things for no good reason.


Duly noted. Post on Swizzling and the new Objective-C literals are forthcoming :)


When you do, please recommend one of the techniques/libraries that properly generate super calls.


Does swizzling really have a place in well-designed software today?

(edit: changed everything. ;-)


I only use it in cases where an underlying framework does not expose or provide the functionality I need (and subclassing is not an option). I wouldn't necessarily say it means these frameworks are not well-designed though.


Yes, at least in unit tests.

Sometimes you need to call stuff which you cannot work around so it is required to patch calls.


It's also useful for developing developer tools (for the same effect as interposing).




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: