0:00:00Hello, and welcome to Developing Perspective.
0:00:03Developing Perspective is a podcast discussing news of note in iOS development, Apple, and
0:00:07the like.
0:00:08I'm your host, David Smith.
0:00:09I'm an independent iOS developer based in Herndon, Virginia.
0:00:11This is show number 78, and today is Tuesday, September 11th.
0:00:15Developing Perspective is never longer than 15 minutes, so let's get started.
0:00:19All right, so I'm going to be continuing on my process that I started in the last show,
0:00:24kind of this arc I'm going to be doing about developing a new project from start to finish.
0:00:31And I really appreciate all the people who sent me questions, feedback, comments about
0:00:35that.
0:00:36I've been collecting them all on Twitter and email and all that.
0:00:39I'm not really able to reply to everybody, so just know that everything you send I will
0:00:43read and I will try and incorporate as best I can.
0:00:47Sometimes there's duplication, sometimes there's not.
0:00:49It's just kind of impractical to actually respond to every person individually for exactly
0:00:53how I do that.
0:00:54But hopefully the results is positive, and I just want to encourage you, if you have
0:00:58those thoughts, I definitely appreciate getting them, and by all means keep sending them in.
0:01:03I really like it on Twitter, just because it's short and succinct.
0:01:06If you're going to send me an email, please try and smush that down to sort of a kernel
0:01:11of what it is that you're asking, just to make my life a little bit easier.
0:01:15And just probably a note, tomorrow is of course announcement day, which is very exciting.
0:01:19I'm recording this on Tuesday, September 11th.
0:01:22Tomorrow, Wednesday, September 12th is the big Apple announcement, new iPhone, all that.
0:01:27I may do an extra episode to cover that, or maybe do it as Thursday's episode.
0:01:31I'll just have to see based on how it goes.
0:01:33All right, so for the main topic I'm going to talk about today when you're building a
0:01:36new project is talking about a little bit of one more thing on prototyping and then
0:01:42how I manage third-party libraries.
0:01:45So first, one more thing about prototyping.
0:01:46I've got a couple of little questions about that, and I think an area that I wanted to
0:01:50cover is just sort of the importance of encapsulation when you're prototyping.
0:01:55And if you're not familiar with encapsulation, or it goes by all kinds of different names,
0:01:58I'm sure, but when I say encapsulation, what I mean is the taking functionality and grouping
0:02:04it into distinct classes so that you organize the logic of your application into smaller
0:02:09and smaller parts that have smaller and smaller roles and more and more focus.
0:02:14And this is really important when you're prototyping.
0:02:17It's in general a pretty good practice.
0:02:18You can get carried away with it for sure.
0:02:20But what I find is really important is
0:02:23sort of having as loose coupling
0:02:26between components as you can.
0:02:28And by that I mean I want to be able to pull things
0:02:31in and out and sort of, oh, change my mind,
0:02:33throw this away, oh, might change my mind,
0:02:34throw this away, and have that effect
0:02:36as few things as possible, or affect things
0:02:38in as defined of an interface as possible.
0:02:41So as an example, I recently completely changed
0:02:45my data provider underneath the weather application.
0:02:48I was trying one, found some things I didn't like,
0:02:50moved to another.
0:02:52Okay, that's great.
0:02:54And what I ended up having to do is I really only had
0:02:56to change it in one place because I'd encapsulated
0:03:00all the data loading functionality into sort of a class
0:03:04two or three level steep so that all my view stuff
0:03:07didn't even know that anything had changed.
0:03:10It was all being provided the data in exactly the same format as it was before, it just
0:03:13happened to come from a different source.
0:03:15And all I had to change was the thing that was doing the setting the URL that I wanted
0:03:20to get the data from, and then my actual sort of parser that was taking that and moving
0:03:24it just from a JSON blob into sort of domain objects in my application.
0:03:29And so by doing that, it made that process really easy.
0:03:31And it was also very dependable for, I knew I didn't break a lot of things in doing that.
0:03:37So that's just something that I do a lot,
0:03:42is when you're creating a new project, especially early on,
0:03:44don't feel scared of just,
0:03:47it's like, "File new file, make a new class,
0:03:51"make a new class, make a new class."
0:03:55Have lots of classes.
0:03:57A lot of them you end up throwing away.
0:03:57I've probably deleted about 12-ish classes
0:03:59since I started this project.
0:04:03Things that I built, tried, didn't work, threw it away.
0:04:03But it allows me to do a lot of things really quickly and really safely, rather than if
0:04:07you end up squishing lots and lots of functionality into one thing.
0:04:10It's really important generally to do that, but it's really, really important when you're
0:04:13prototyping early on to do it.
0:04:16Because you feel like you're saving time.
0:04:18If you're sort of, "Oh, I'll just throw everything into this one logic, or in one place.
0:04:23I'll have my one view controller that has everything in it."
0:04:26There's a place for that maybe, but if you're ever ... And that's really only for true throwaway
0:04:32prototypes I could see doing that,
0:04:37where you are building something expecting to throw it away.
0:04:39It's like a proof of concept.
0:04:42Maybe you can do probably your logic into a view controller.
0:04:43But if you're building something that you're expecting
0:04:46to actually ship at some point,
0:04:47but you're prototyping it, your early phases,
0:04:50your early iterations on it,
0:04:52then it's important to break things up as much as you can,
0:04:54because it gives you so much more flexibility and speed
0:04:57while you're doing that prototyping phase.
0:04:59And so then the next thing I was going to talk about
0:05:04is managing third-party libraries.
0:05:06And I got a lot of feedback on that,
0:05:08and I got a couple people who said it was great,
0:05:10that I said, "Oh, I use AF networking.
0:05:12It's the best."
0:05:14And there's a lot of third-party libraries
0:05:15that you'll end up using typically,
0:05:17and often you're going to want to talk,
0:05:19you want to use third-party libraries,
0:05:21but they make your life easier.
0:05:23And that's a very hard thing to judge, potentially.
0:05:26It's often sometimes like, "Oh, here's this guy
0:05:31who does this library that does exactly what I want."
0:05:33Make sure that it is actually exactly what you want.
0:05:36Typically what I find is I never really use
0:05:38third-party libraries for functionality that is,
0:05:41I suppose, specific to my application,
0:05:45or in the same problem domain as my application.
0:05:48I almost always write that custom,
0:05:50because it's very unlikely that a third-party
0:05:52general-purpose solution is going to fit
0:05:52for what exactly I want.
0:05:57Where third-party libraries and open-source code
0:05:58really come into play is when you are doing something
0:06:00that's very orthogonal, that's very distinct
0:06:04from your application.
0:06:06So the great example there is something like a networking stack.
0:06:07My app is not about networking.
0:06:10I don't really care how I go from a URL to a blob of JSON.
0:06:11I just want a URL blob of JSON.
0:06:16And so ASN like AF networking makes that really, really simple for me
0:06:17and handles a lot of the weird edge cases,
0:06:22and things that I'd have to do anyway.
0:06:24Another example is JSON parsing.
0:06:27I don't really care how I go from a JSON string
0:06:29to a collection of NS dictionaries,
0:06:33NS arrays, NS numbers, NS strings.
0:06:37I don't really care how that translation happens,
0:06:41so I go ahead and do it.
0:06:43Using that as a broad guide, though,
0:06:43I think is really constructive,
0:06:48to make sure you're not doing things
0:06:50that you really don't want to.
0:06:52And so that's sort of the first part,
0:06:55is how do you decide when to use one?
0:06:57And it's always worth playing around with
0:06:59and looking around, seeing what people have done.
0:07:02What I find I do more often than necessarily using
0:07:03third-party libraries in open source is I'll look for
0:07:06inspiration inside them.
0:07:08So if someone's done something similar to what I'm doing,
0:07:09So say someone's doing, as an example,
0:07:14I do, in my weather app, I have some charts
0:07:17for showing the forecast over the day
0:07:20and some of those kinds of things.
0:07:23And I don't, there's all manner of third-party
0:07:25graphing clients that I could use.
0:07:29But the thing that I was looking at is,
0:07:32the thing is, what I want is,
0:07:34I want it to look a very specific way.
0:07:35And this is what I'm getting at,
0:07:37where I have a very specific domain need for my application,
0:07:37So it doesn't necessarily make sense to do it just generally like that.
0:07:42And so instead of using a third-party plumbing library, what I did is I wrote my own.
0:07:46But I went and I looked around at how other people are doing charts, how other people are doing graphs.
0:07:55Just looking in their code.
0:07:59Don't feel like you're going to GitHub, you can browse the project right there, you can look at the code, see how, "Oh, that's how they do it."
0:08:03and that's how they got their performance up, or whatever.
0:08:08That's a great tool for a third-party code
0:08:12that you then are picking and choosing the concepts
0:08:15and bits and pieces from that project,
0:08:17but then ending up with a really custom,
0:08:20sort of highly-tuned version of that
0:08:23for your particular application.
0:08:25So that's something else I do.
0:08:27And then lastly, what I wanted to talk about
0:08:28is how I organize my third-party libraries.
0:08:30And I recently, and this is the first time
0:08:29I've ever done it for this project, I started using a thing called CocoaPods.
0:08:34And CocoaPods, if you're familiar with a package manager from another language, say for example
0:08:39like gems in Ruby or I think Python, PHP, a lot of them have these kind of things that
0:08:45are designed to bundle up functionality in a way that is easy to sort of pull in and
0:08:51out, that you can version well, that you can reference directly in your source control.
0:08:56And CocoaPods is one that's designed to do this for Objective-C projects.
0:09:02And the great thing about it is it integrates really well with Xcode.
0:09:05And so a little bit of sort of how it does it, I recommend just looking at their website
0:09:10and going from there.
0:09:11But what CocoaPods do is it takes your Xcode project and moves it inside of an Xcode workspace,
0:09:19which if you're not familiar with, a workspace is just a collection of projects that Xcode
0:09:23is aware of.
0:09:25and you can share code between and kind of when you build, it builds both projects.
0:09:28But it creates its own project, the pods project, that handles all the third-party libraries
0:09:34for you.
0:09:35And so that has this really nice effect of separating them out from your code so you
0:09:39don't have to worry about them there.
0:09:41And it's also handling all of the other stuff that you would sometimes need to do in terms
0:09:46of linking frameworks and all this stuff.
0:09:48All the extra frameworks that you need for this are all pushed over into the pods directory.
0:09:53They're not in your own code.
0:09:55And so that's really nice from a cleanliness perspective
0:09:58of keeping your project clean and light.
0:10:00And whenever you install a new pod, I guess they'd call it,
0:10:05it adds it to that, it updates its own Xcode project.
0:10:08It's a project that you should never edit yourself,
0:10:10because it's always going to be overridden,
0:10:12and it's kind of like CocoaPods manages that for you.
0:10:14But it works great.
0:10:15And you want to add a new one, you just
0:10:17added it to your pod file, which is a little thing where
0:10:19you specify, like, I want AF networking version 1.0 RC2.
0:10:23or whatever my current one is, and you say pod install,
0:10:26and it installs it.
0:10:27That's it.
0:10:28You can say pod-- you can delete it, and then do pod install,
0:10:31and it'll delete it.
0:10:33You can search for different ones.
0:10:34You can do like pod search, JSON,
0:10:36and it'll give you a list of JSON file-- of JSON libraries
0:10:39that exist that you can choose from.
0:10:41There's a lot of really nice things like that,
0:10:43that I've started using it, and I think I really will probably
0:10:46be moving forward.
0:10:47If you're a third-party library developer,
0:10:49I highly recommend creating a pod spec
0:10:50file for your library.
0:10:55It makes it really easy for other people to integrate with,
0:10:58and it's really straightforward.
0:11:00I mean, they make it really easy.
0:11:01Another nice thing, too, you can also have private pods.
0:11:04And I've done this myself for one of the little components
0:11:07that I have internally.
0:11:11So this is code that's not publicly available,
0:11:12but it's in a private GitHub repository.
0:11:15But you can just create a pod spec for it and link to it,
0:11:17just like you would normally.
0:11:16And so you can manage your own dependencies internally
0:11:19this way, too, which is kind of nice.
0:11:22So definitely worth checking out,
0:11:23and I highly recommend it.
0:11:24There'll be a link in the show notes to the CocoaPods project.
0:11:28All right.
0:11:29So that's sort of the main two topics I'm going to talk about.
0:11:31And to kind of round out our 15 minutes,
0:11:33I'm just going to sort of do a little speculation,
0:11:35a little talking about the new iPhone, what I'm hoping for,
0:11:39what sort of things I'm thinking about as it's coming out.
0:11:43So there's a couple of things that I don't really care about.
0:11:48I mean, whatever it is, I'm going to buy one.
0:11:49That's sort of a given.
0:11:50It doesn't matter what it is, what it costs.
0:11:52This is what I do for a living.
0:11:54So whatever Apple's new hotness is, I'm going to buy one.
0:11:56I'm probably going to buy it unlocked this time,
0:11:58just because I'm not--
0:12:00I'm still on contract with AT&T, so I'll just
0:12:02need to buy a new one.
0:12:04Flat out, that's probably better in terms
0:12:06of gradually releasing the shackles AT&T has on me.
0:12:11Things that I'm a little nervous about is 16 by nine.
0:12:16It's weird because if the screen is a 16 by nine resolution
0:12:21and there's a couple of things you can do to hack
0:12:25the simulator to make it look like 16 by nine
0:12:27and see how your applications respond.
0:12:29And my apps do pretty well.
0:12:31Overall, it's fine.
0:12:33And especially this app that I've been, my weather app,
0:12:35I've been building from the beginning
0:12:37to be 16 by nine flexible.
0:12:39So in the vertical dimension, it's very flexible.
0:12:39But the thing that I worry about is a lot of these apps, I think, look funny in 16 by
0:12:449.
0:12:45And by that I mean you have so much space to put information on, and the information
0:12:52is so tall, that you end up with this really strange kind of look to it.
0:12:57Maybe it's just not what I'm used to, but it feels very stretched and odd in that way.
0:13:03And so I'm sure we'll get used to it, whatever it is, but that kind of makes me nervous.
0:13:06And as I've been looking at my layouts and my designs,
0:13:09I don't like the aesthetic of 16 by 9 nearly as much
0:13:12as I do the current dimensions we have on the iPhone.
0:13:15But if that's where they're going,
0:13:16that's where they're going, I'll just get used to it
0:13:19and adapt accordingly.
0:13:21Things that I really want in the new iPhone is more storage.
0:13:24I'd love for the new ones to be rather than 16, 32, 64.
0:13:28I would love for the base model to be 32,
0:13:31just because I think that's really what I probably want,
0:13:34is about a 32 gig.
0:13:35be nice for it to be $100 less.
0:13:38And otherwise, I don't really care.
0:13:40I mean, there's so many things that Apple
0:13:41could do this, this, and the other.
0:13:43It's like, if it has LTE, that's great.
0:13:46I hope that works.
0:13:48I'm still on the needTNT unlimited plan
0:13:51from back in the day.
0:13:52So I have no idea if that would work with LTE.
0:13:54And if it does, great.
0:13:55I got a nice, fast connection.
0:13:57This is where I am.
0:13:58I have pretty good AT&T LTE coverage.
0:14:00I know it varies based on where you are.
0:14:03NFC doesn't really make any sense.
0:14:05A slightly slimmer form factor, sure.
0:14:08Better battery life, maybe.
0:14:10If they could squeeze out more battery life, I'd love it.
0:14:13But I'm not really holding my breath on that.
0:14:15And otherwise, I just look forward to enjoying the ride.
0:14:17I'm sure there will be some cool things on iOS 6
0:14:19to take advantage of.
0:14:20And it's an exciting time as a developer.
0:14:23I know I'll sort of get out the popcorn,
0:14:25enjoy watching the live blogs.
0:14:26And I hope you do too.
0:14:28All right, that's it for today's show.
0:14:30As always, if you have questions, comments, concerns,
0:14:32I'm on Twitter @_DavidSmith.
0:14:34And otherwise, I hope you have a good announcement day.
0:14:36Enjoy it, and I'll talk to you afterwards.
0:14:38Bye.