Inheriting Code:
Tips for inheriting iOS code
Presented at NSLondon January 2014 in the Pecha Kucha style
Video: http://vimeopro.com/user20904333/cocoakucha-london/video/86569642
2. Who am I? @mostgood
✤ Started writing iPhone apps in 2008 !
✤ Head of App Development at Dennis Publishing (we’re hiring!)!
✤ Best of 2013 - Newsstand
3. Inheriting code
✤ Code that was written by someone else that you have to maintain!
✤ How many of us have inherited code?!
✤ Try it if you haven’t - it’s amazingly fun and educational, and only
occasionally painful
4. Why inheriting code?
✤ Had a new iOS developer join last week!
✤ There has been a lot of !
“Why was this done?” !
“How does this actually work?”!
and general anger at the people who wrote it...
5. “Why do I need to open Xcode?”
✤ Some rampant bugs need squashing!
✤ The app looks dated!
✤ Add new features!
✤ Legal issues!
✤ API deprecation
7. Stalk your prey
✤ Go through documentation!
✤ Look through commit history!
✤ Issue tracking!
✤ Crash reports!
✤ Become obsessive
8. As you go
✤ add comments!
✤ add pragmas!
✤ document how it works!
✤ keep track of known issues!
✤ add tests
9. Quick fixes
✤ Update 3rd party libraries/frameworks!
✤ Basic refactoring!
✤ Drop support for older OS versions if possible!
✤ Run ‘Convert to Modern Objective-C Syntax’, etc
10. Not so quick fixes
✤ Standardise: Replacing XYMagicGridView with UICollectionView!
✤ Modernise: NSURLConnection -> NSURLSession!
✤ Updating persistent storage type: Plist -> CoreData!
✤ Complicated refactoring
11. It’s too broken: rewrite all the
things
✤ Declare bankruptcy on technical debt!
✤ Shoehorning!
✤ Latest and greatest
12. This isn’t working: rewrite all the
things
✤ booBoo.surfaceArea > plaster.surfaceArea!
✤ Making it worse!
✤ Ghosts in the code
13. “Why is it like this?”
✤ Did people really not care about quality and maintainability?!
✤ Possibly!
✤ But there is usually a reason why
16. Don’t point fingers
✤ We all do stupid things!
✤ There are always circumstances!
✤ If you haven’t already, you’ll create something that will torture
another developer someday
17. Open a dialogue
✤ If possible, get in touch with who worked on it before!
✤ Talk to people who are maintaining your code!
✤ Find people at conferences, meet-ups, twitter, etc...
18. “It’s good to talk”
✤ It shows you how far you’ve come!
✤ Grounds you!
✤ Learn something new!
✤ Teach someone something new!
✤ Shows respect!
✤ Strengthens community
19. What’s your legacy?
✤ When you write code, think of the next developer!
✤ Document and comment!
✤ Write meaningful commit messages!
✤ Coding standard!
✤ Readability!
✤ Write tests (if you’re into that sort of thing)
20. Insurance Premiums
mild WTF Good Better
Ultra-über-
awesome
Comments x x x x
Documentation x x x
Issue tracking x x
Refactor x x
Coding standard x x
Readability x
Tests x
Price: < hour few hours a day few days