Podcast Search

Under the Radar

70: The Hacks We Ship

Select a time to play from there. The line being spoken is highlighted as the audio plays.

0:00:00Welcome to Under the Radar, a show about independent iOS app development.

0:00:03I'm Marco Arment.

0:00:05And I'm David Smith.

0:00:06Under the Radar is never longer than 30 minutes, so let's get started.

0:00:10So today we are going to be talking about hacks.

0:00:15About the hacks that we ship, the hacks that we probably shouldn't ship, and in general

0:00:21kind of what they are.

0:00:22I mean, I think it's a term that is often thrown around in development, and sometimes

0:00:26in a pejorative way, and sometimes in a praising way.

0:00:32Which is always kind of interesting when you have a word that can be both something that's

0:00:35really good and awesome, and something that is awful and terrible and no good.

0:00:41And so I think it's kind of a fun topic to just kind of unpack and talk through maybe

0:00:46some of the good hacks, the things that are really cool and clever, the things that are

0:00:51kind of in the middle ground where it's like, "Ehh, it's starting to get a little questionable."

0:00:56And then some of the hacks that we probably should never ship.

0:00:58But sometimes we do.

0:01:00Yeah.

0:01:01Oh yeah, so that is I think the tricky thing.

0:01:03If you're not aware of which bucket it had particular hack falls into, you may start

0:01:10to really fall into these traps a little bit more easily.

0:01:14So when I think of a hack, I was trying to think of a good operative definition to kind

0:01:21of separate it from just regular development.

0:01:23And I think when I think of a hack, I think of something that is either a shortcut, like

0:01:29either just like I'm finding a way to solve a problem that is kind of skipping over a

0:01:36bunch of usually required steps, or it's kind of like an oblique solution to the problem.

0:01:44So rather than like solving the problem in the way that you would expect to, or like

0:01:49the natural solution, you find a way to have a solution that works.

0:01:54And often a hack will kind of solve 99% of the problem, but not the 100% of the problem,

0:02:00but you're okay with that because it does it in such a clever and clean way.

0:02:05But it's typically about rather than doing the, I don't know if you can call it like

0:02:10the academically correct solution to a problem.

0:02:13Like the hack is the finding a way to do it by abusing some kind of one of the system

0:02:20APIs or working around a system API in a weird way.

0:02:24But in some way or other, you're kind of going around things in a non-traditional approach.

0:02:30And ultimately I find that your ability to do these kinds of solutions can be really

0:02:36powerful.

0:02:37Like it's a funny thing to say, but I think I'm pretty good at finding these.

0:02:40I don't really know exactly what part of my mentality.

0:02:43I think it's just the profound laziness that I tend to have in life.

0:02:46It's the best kind of programmer.

0:02:48Yeah.

0:02:49It makes me look for these.

0:02:50Like it makes me look for like, huh, is there a way that I could, you know, if I'm looking

0:02:55at this, this big complicated feature, I'm like, is there a way that rather than actually

0:03:00solving it, I can kind of solve it?

0:03:03Here's a bunch of work in front of me that I don't want to do.

0:03:06Is there a way I can not do it?

0:03:08Yep.

0:03:09That's basically it.

0:03:10And often there is.

0:03:11Like when you start looking at these big scary problems, you often find these really novel

0:03:17solutions that aren't as maybe academically or professionally as good or as clever, but

0:03:27like get the job done.

0:03:29And if it gets the job done, it gets the job done.

0:03:31And so I'm always on the lookout for these.

0:03:33And I think in general, it's a great tool for getting things up and going.

0:03:37And especially, you know, like the Nap Store is a pretty dynamic environment where being

0:03:41able to do things more quickly than your competitors is an advantage.

0:03:47Like it is definitely an advantage to be able to do things more quickly.

0:03:50And you know, the ability to find these shortcuts and find these oblique solutions to problems,

0:03:55I think is a great, it's one little like tool in the toolbox to help us, you know, sort

0:04:00of stay ahead.

0:04:01Yeah.

0:04:02And I, the thing about finding a good hack is it's just so incredibly satisfying.

0:04:10Like I love, like, and it's, you know, it's a kind of thing where like it's satisfying

0:04:16both as a lazy person of like I just avoided a whole bunch of work.

0:04:21But also just like as like an intellectual, you know, or a programmer, it's like you

0:04:26get satisfaction out of cleverness, out of clever solutions.

0:04:30And I just, I get so much joy out of it.

0:04:33Like one of the favorite things I discovered recently was, do you remember, did you see

0:04:37this back like in like, I think it was the Quake source code.

0:04:41There was a method to do a fast inverse square root.

0:04:45And this is something that games have to do a lot while rendering textures and stuff.

0:04:49And you know, if you, and like square roots operations are complex mathematically, but

0:04:54there was a way that, here it was, here I just found it.

0:04:58It's in Quake 3 arena in the code.

0:05:01And you know, like John Carmack is famous for being like an incredible programmer with

0:05:04this kind of stuff.

0:05:06And he probably wrote this or adapted this from whatever.

0:05:08And like you totally bypass doing an actual reverse square root operation or inverse square

0:05:14root operation by just like a bit of like bit shifting and quick math that's really

0:05:18fast to do on processors.

0:05:19And it includes this weirdo constant.

0:05:22You like bit shift by this one weird constant, you know, like five F three seven something.

0:05:26And in the source code, he actually wrote what the F like next to it, like what is this

0:05:31number?

0:05:32But it works and it generates like an approximation of the value that you need.

0:05:38And it's something like 99% accurate, which is like good enough for a game purpose in

0:05:43way less time on the processor than doing like the actual mathematically correct operation.

0:05:47That's like, that is an amazing, amazing hack.

0:05:51And that like, like the day that that was discovered by somebody must have felt amazing.

0:05:56Like and like, so you know, like whenever I have like, you know, a day, like usually

0:06:00I don't have a day like that where I discover a new way to do math.

0:06:03But you know, I do often find like time savers or shortcuts or, or the ability, as you said,

0:06:10really like the ability to like to, to do something that I wasn't supposed to be able

0:06:14to do.

0:06:15Like styling a certain element a certain way in the app or, or you know, a certain UI behavior

0:06:21or a certain animation getting quite right.

0:06:25And really like the best apps are filled with glorious, awful hacks because you know, usually

0:06:30to do, to do whatever is considered making an app great at any given time almost always

0:06:37involves some degree of like clever or horrendous hacks because oftentimes you're, you're

0:06:43thinking around, you know, UI framework limitations or abilities of the platform that are, are

0:06:50possible but really hard or you know, kind of edge cases that you don't usually need

0:06:54to do.

0:06:56And if you do glorious hacks effectively, you can set your app ahead.

0:07:02You can make an app that people, that, that, that people take notice of, that, that does

0:07:06something noteworthy or newsworthy.

0:07:08And that can help you.

0:07:09Not to mention the fact that as an independent, it can save you a bunch of time if you learn

0:07:12how to hack well.

0:07:14But you know, I think it's a question of like deciding when to try to find a glorious hack

0:07:19to something and when to just say no thanks.

0:07:23And that's, that's trickier than, than some of the hacks themselves.

0:07:26Yeah.

0:07:27Though I do think it's like, I think what you just hit on there is I think the, the,

0:07:31the best kind of hack, like the one that I think is so, it's like the thing, you know,

0:07:35the thing that I love is when you are able to use a hack to do something that shouldn't

0:07:40be possible.

0:07:41Right.

0:07:42Like given whatever kind of what you're defining as possible, but like you come up with a way

0:07:46to do something like, you know, in that example, it's like doing this math operation really,

0:07:50you know, efficiently, like that shouldn't be possible.

0:07:53Like it's, it's, you should only be able to do the math the way the math is, but like,

0:07:56it's just somehow you're able to do it.

0:07:58And from a developer, an app perspective, it's like, if you can do this thing that shouldn't

0:08:02be, that shouldn't really be possible, but you find a way to do it, then you're necessarily

0:08:08like putting yourself at an advantage towards your competitors because from their perspective,

0:08:12it still is impossible.

0:08:13Like it still is ridiculously computationally intensive or just, you know, a lot of times

0:08:18you'll run into these things in, you know, there's just, you find a way to hack with

0:08:22the frameworks that Apple gives us in a way that gets you, allows you to do something.

0:08:27And like the one that I am still probably to this day, the most proud of was in parameter

0:08:32plus plus, which, you know, it's a step counter.

0:08:34And so I'm added a feature where it could show you your step count on the, as the badge

0:08:42for the application itself.

0:08:44I mean that alone is a hack, right?

0:08:45The idea of using the, of using like the red alert badge as to represent a value that's

0:08:52like in the thousands as a step count instead of like a message chat or something, that

0:08:56is itself a glorious hack.

0:08:58Yeah.

0:08:59Nope.

0:09:00That is the, that's not even the cool hack.

0:09:01Like that was just kind of like, huh, I wonder if I can think of, cause this was in the days

0:09:06before today view widgets.

0:09:07And so I was like, how can I show you your step count without launching the app?

0:09:10Like, Oh, what if I make it a badge?

0:09:12Okay, that's great.

0:09:13And it worked all right.

0:09:15And turns out though that once you get to really big numbers of badges, because I'm

0:09:20abusing the API, I discovered that it would start to truncate, you know, so if you, once

0:09:26you got to above typically it was about 10,000, the 10 thousands of steps.

0:09:32So once you hit 20,000 steps, the badge would start to truncate and it would just be like,

0:09:37you know, two dot, dot, dot six is all that would show when you, you know, rather than

0:09:41showing the actual step count.

0:09:44And for a while I was just like, Oh, that's fine.

0:09:45Like how often do people actually going to, you know, does it really matter that once

0:09:49you've hit 20,000 steps that it did truncates, but it bothered me.

0:09:54Like, you know, in the back of my mind, I'm like, I really don't like that.

0:09:56There's got to be a way to work around it.

0:09:59And one day, of course, it was while I was taking a shower, because that's where I

0:10:02have all my best ideas.

0:10:03Of course.

0:10:05I had the thought, I was like, I wonder if I can rather than if the actual number that

0:10:12I display there is important for what gets truncated, because it's why it goes from

0:10:17what, you know, 10,000 to 20,000, it starts to truncate.

0:10:20And it turns out, it gets truncated if you have, you know, the numbers are too wide,

0:10:26because it's proportional font.

0:10:28And so if I put a lot of ones in the number that gets displayed, it doesn't get truncated.

0:10:35And, you know, this is why 10,000 doesn't get truncated, but 2000 does, because 2000

0:10:40is wider.

0:10:42And so once I had that, you know, test try that out, then I, what I've started to do,

0:10:46but I started to think is like, huh, what if I just changed the step count so that it

0:10:51always includes at, you know, at least when it's five digits long, it has to include

0:10:55at least one one.

0:10:57And when it's, you know, gets longer, you start to increase the number of ones that

0:11:00it starts to do.

0:11:02And it worked.

0:11:03So if you, so if you once you get above 20,000 steps, the last digit is always a one, which

0:11:10most customers will never notice, because it's the least significant digit, like the

0:11:14difference between one, you know, the number ending in 21 and 23.

0:11:18Like you're not going to really notice, you're mostly focused on the, you know, the more

0:11:21significant digits at the front.

0:11:23So I just sit there and I go through and I take, you know, I take the number and I just

0:11:26count the number of ones.

0:11:27And if there's not enough, then I add one at the end and replace that digit.

0:11:32And I go from there.

0:11:33And it's this like awful hack that kind of changing the, you know, I'm just dynamically

0:11:37changing the step count so that the badges doesn't truncate.

0:11:40But it works.

0:11:41So I was able to abuse this system API for badges that was never really intended to display,

0:11:46you know, numbers in the 20,000s and 30,000s.

0:11:49Like if you have that many unread email, emails on the mail app, like that's not really telling

0:11:55you anything.

0:11:56It's just telling you, you have a lot of things.

0:11:58And so Apple never really intended for this badge to be accurate, you know, to this and

0:12:02this and this many digits.

0:12:03But if you just randomly, if you just sort of go through and replace the, you know, digits

0:12:08with a lot of ones that are nice and thin, it works.

0:12:12And like that's the kind of hack where it takes something that doesn't seem like it

0:12:14should be possible.

0:12:15Like it shouldn't be possible to display the number 20,000 as a badge or an app icon.

0:12:21But you know, find this kind of glorious hack by switching out a few digits and then it

0:12:26was possible.

0:12:27And like those are the best kind of hacks.

0:12:28The places where we can make something that doesn't seem like it should be possible actually

0:12:33work.

0:12:34And in that kind of case, like that was also good because there were really no massive

0:12:39side effects to it.

0:12:40Like you weren't like, you know, like if, you know, the worst case scenario was Apple

0:12:44updates the OS and the font is slightly different and the bounds of that box is slightly different

0:12:49and then it doesn't fit anymore at all.

0:12:51But you know, ultimately like that's a pretty safe hack because like worst case scenario

0:12:56you got to update something, you know, later on but it's not going to break, you know,

0:12:59like that's, and it doesn't really touch anything else.

0:13:01And you are technically corrupting the display of the data but in a way that doesn't matter.

0:13:09So like that's glorious, you know.

0:13:11And this reminds me like, you know, a lot of times, you know, you can build a whole

0:13:15feature on hacks.

0:13:16Like you know, the entire badge icon feature is itself a glorious hack.

0:13:23You know, back when I did Instapaper, the very first pagination algorithm I did, this

0:13:28was, you know, now I think it's a lot easier on a web view.

0:13:31I think they just built it in.

0:13:32But back then there was no built in way to offer pagination of a web view.

0:13:38You could scroll it and that was it.

0:13:41That was, you know, your only choice.

0:13:43And you could programmatically scroll it but, you know, there was no way to like split the

0:13:47content into pages.

0:13:48Even like WebKit now has ways to do that I think but it didn't back then.

0:13:52And so I brainstormed lots of different ways that I could like figure out where the page

0:13:59breaks were and paginate a large rendering of a webpage.

0:14:04But because I had control over the background color and I knew that it was always normalized.

0:14:12It was always like, you know, either your background color is either white or black

0:14:15or whatever it is and like that's it.

0:14:18And I also knew that I was doing things like sizing images and stuff such that they were

0:14:22never taller than one page of the screen and things like that.

0:14:25And so my crazy idea was, you know what, and this was back with the iPhone 1 hardware,

0:14:33and that was a pretty slow device.

0:14:34I'm like, you know, if I just take like a screen grab of the rendered page and just

0:14:43search for like what is the, like go from the top and the bottom and try to find like

0:14:49where is a solid color line of pixels.

0:14:54And then just draw opaque views.

0:14:56Once I find like where the solid lines of pixels are, basically draw like curtains,

0:15:01one on top, one on bottom, to just black out the area up to that point.

0:15:06And then I have pagination.

0:15:08And all I have to do is when the user turns the page, draw the screen up, you know, scroll

0:15:15up to the next page and then before it displays to the user, like during the same iteration

0:15:21of the run loop, before it displays to the user, render it again to a bitmap, find that

0:15:26next line and put those curtain views where they need to go.

0:15:29So the user always sees consistent pages and it never breaks.

0:15:34I thought there is no way this is going to work on the iPhone 1 and it did and it was

0:15:40fast and it was great.

0:15:42And the only downside was that if you had a line that included all lowercase letters,

0:15:48it could theoretically and sometimes did cut dots off of i's and j's and put them on separate

0:15:54pages because it could slice between the line, like the one pixel line between the i and

0:16:01its dot, it could cut a page there because it didn't have any concept of line height

0:16:06of the text being shown.

0:16:08And that was the original pagination algorithm and it worked great.

0:16:11And it was fast and that was the only downside and it didn't matter really much, you know,

0:16:16it hardly ever was actually a thing.

0:16:18So it was glorious and I could build this entire feature and because I had come up with

0:16:24this crazy hack, actually had the initiative to try it and then was able to technically

0:16:28do it and then of course had the guts to ship a horrible hack like that.

0:16:34Because of that, I had this like must have feature of read later apps that no one matched

0:16:42I think for like two years or something.

0:16:43It was a long time before anybody else had pagination and that gave me a competitive

0:16:47advantage and it was a great feature to use.

0:16:49It was fun, my users liked it, I liked it and so it was kind of like, the only downside

0:16:55was I didn't know if it would work in the future and this was always a problem but it

0:16:59seemed like a pretty safe bet and it indeed did work.

0:17:03I think I did eventually change the algorithm but I think it would have worked for basically

0:17:09indefinitely into the future and I absolutely loved it.

0:17:12Yeah and I think that speaks to some of the best sources of these kind of like these glorious

0:17:17great hacks.

0:17:19Is whenever you can think of the problem from a completely different perspective.

0:17:25So in this case you took something that was like the usual solutions would involve dealing

0:17:30with the HTML, right?

0:17:32Dealing with the text itself and instead you're like, eh, rather than dealing with any of

0:17:38that stuff that sounds really hard, I'm just going to think of it as a bitmap.

0:17:42And like you completely take the problem and turn it around when rather than dealing with

0:17:46like the really hard problem domain of like HTML layout and things that are just really

0:17:52hard problems, it's like, you know what?

0:17:54Bitmaps are easy, they're just arrays of arrays.

0:17:57That's a really, like anytime you can kind of find a way to do that, it's these really,

0:18:02I remember when I was doing computer science at college where you'd have these, and obviously

0:18:07this was like an intentional exercise, this was a journey the professor was intentionally

0:18:12taking you on where you start off with this really like naive solution that's kind of

0:18:18really hard and tricky and then all of a sudden you end up at the end of this journey and

0:18:22you're like, you're solving this problem in a really clever and novel way.

0:18:27And usually it's like there was this magic point where you rather than solving the problem

0:18:30directly, it's like you went around back and came in the side door and suddenly all these

0:18:36other things are possible.

0:18:37All these other things that should be hard suddenly aren't hard because rather than dealing

0:18:43with text, you're dealing with pixels.

0:18:45Or rather than dealing with the obvious solution, you're dealing with something differently.

0:18:51You're not dealing with the raw data itself, you just deal with some other kind of meta

0:18:55situation on it.

0:18:56And that switch, that little insight that you can have is usually the source, I think,

0:19:03of the best kind of hacks.

0:19:06We are sponsored this week by Dice.

0:19:08Dice has been helping tech professionals advance their careers for more than 20 years.

0:19:12They have the tools and insights needed to give you an edge.

0:19:15The Dice Careers mobile app is the premier tool to manage your tech career from anywhere.

0:19:20With thousands of positions from top companies, you'll find exactly what you're looking for.

0:19:24And if you're wondering what's next in your career, Dice's new career pathing tool can

0:19:28help you learn about new roles based on your job title and skills.

0:19:32They'll even show you which skills you'll need to make the next move.

0:19:36And so the Dice Careers market value calculator allows you to understand what your skills

0:19:40are worth.

0:19:41You can discover your market value based not only on your job title and location, but also

0:19:45your specific skill set.

0:19:47So don't just look for a job, manage your entire tech career.

0:19:51And Dice will help you do that.

0:19:53Download the Dice mobile app and you can learn more at dice.com/undertheradar.

0:19:58Once again, download the Dice mobile app and learn more at dice.com/undertheradar.

0:20:03Our thanks to Dice for sponsoring this show and all of Relay FM.

0:20:07So not all hacks are glorious though.

0:20:11There are some hacks that are probably best left behind or the ones that at least you

0:20:15need to be incredibly careful about doing.

0:20:19And I think those tend to, at least from my experience, they come in kind of two categories.

0:20:23There's the ones that you should never ship with that are really bad and dangerous.

0:20:27And then there's the kind of like, "Mmm, maybe this is okay."

0:20:31So I think of things like all the hacking that we end up doing to poor UITableView,

0:20:36where we do all these things to kind of make some behavior work, but we're kind of abusing

0:20:42the API in the way of doing this.

0:20:44Or we use an API because it kind of lets us easily solve the problem when we know that

0:20:50a better solution exists.

0:20:52And so for that I think of something like using Background App Refresh.

0:20:58For example, in a podcast app, you could use Background App Refresh to keep the subscription

0:21:04list up to date.

0:21:05Or you could do server-side crawling.

0:21:07And server-side crawling is hard, but you can kind of make it kind of work with Background

0:21:10App Refresh.

0:21:12But it's kind of a hack because it's never going to be as good and a better solution

0:21:16does exist and you're intentionally working around it.

0:21:20It's fine, it's probably okay.

0:21:22I think that kind of hacking, especially the things that we have to do around UIKit,

0:21:26where it's like, "I want to style this element and I find some kind of weird way

0:21:31to do it."

0:21:32Or I find a way of, you know, like I remember trying to do something where I was inserting

0:21:37elements into the top of a UITableView without affecting the current scroll position of the

0:21:45UITableView, which seems like it should be somewhat straightforward but is actually fiendishly

0:21:51hard.

0:21:52And you just end up with these crazy hacks, you know, adjusting.

0:21:56You kind of work out how the UITableView, how many pixels down it would shift down,

0:22:02and you're in the same run loop shifted up.

0:22:05But what happens if the user is touching it and scrolling while you do that?

0:22:09All kinds of weird things happen.

0:22:10You end up with these kind of awful hacks that don't work 100% of the time.

0:22:14But you know, will work well enough most of the time, but are often kind of an essential

0:22:19part of being an iOS developer.

0:22:21So we kind of have to hack on these things.

0:22:23And we kind of use these APIs in ways that they're really not intended for.

0:22:29But when we do this, you know, it's probably good to keep in the back of our mind that

0:22:31we are kind of hacking and we are doing these things that are almost certainly going to

0:22:35come back to bite us at some point.

0:22:38Oh yeah.

0:22:39I mean, because, I mean, the thing is, like, you know, many of the UI hacks, like, you

0:22:44know, something like a feature hack or something like, you know, something that's kind of

0:22:49confined to your own code and your own components is way safer and a much, like, better idea

0:22:55usually than hacking UI kit stuff.

0:22:59Unfortunately, hacking UI kit stuff is often what we need to do.

0:23:03And this is what makes, you know, so many of us depend on horrible hacks.

0:23:07And you know, much to the chagrin of the Apple staff members whose job it is to deal with

0:23:13us and the ramifications of us doing this.

0:23:16We apologize.

0:23:17But, you know, oftentimes that's what you need to do.

0:23:20And fortunately, over time, as UI kit has gotten more mature and has gotten kind of

0:23:25more built out, there are so many capabilities that are just built in now using officially

0:23:29supported methods that before you'd have to do horrible hacks to achieve.

0:23:33So certain appearance techniques or, you know, different behaviors, different traits.

0:23:39But still, like, even in this day and age, like, here I was just shipping over CAS3 with

0:23:42tons of table view hacks.

0:23:45And even, like, even the collection view.

0:23:47I hacked the collection view in my add podcast screen because I add a search controller to

0:23:53it.

0:23:54And UI search controller is itself a giant pile of hacks that shouldn't work but somehow

0:23:59does.

0:24:00And I, it really doesn't want to work in a collection view.

0:24:03I have been unable to make this work consistently reliably in one way.

0:24:09That is, since Overcast 1.0, if you type in a search query in my search box in the add

0:24:14podcast screen and you select it and you hit copy in the pop up menu, it crashes.

0:24:22It crashes deep within UI kit in some weirdo method.

0:24:26This bug has been there since 1.0.

0:24:28People report it to me almost every day.

0:24:31But I can't fix it.

0:24:32I have tried so many different things to fix it.

0:24:34I can't fix it.

0:24:35The only way I can fix that bug is to not use UI search controller on that screen.

0:24:41And that is a significant re-architecting and the result would be worse.

0:24:46So I've just kind of decided, you know, it's not something that people do very often.

0:24:50The results aren't that bad.

0:24:52I mean, it crashes, which is embarrassing, but I think it's long shabby and it's fine.

0:24:56So I've decided for now that that's actually worth the bad hackness because the solution

0:25:03of rewriting it to be something else is actually worse to me than that because it's such a

0:25:09rare action anyway.

0:25:12But I recognize that's a terrible hack.

0:25:14In order to get a search controller working in a collection view, you've got to do some

0:25:17weird stuff and it clearly is not made for that and I have no idea how to ever make that

0:25:22work.

0:25:23But I did it and it worked and it's fine.

0:25:25But sometimes that's the wrong idea.

0:25:27Yeah, and I think too it speaks to the, there's this funny line that you will eventually get

0:25:34I think an instinct for, of like, at what point of hacking UIKit have you gone too far?

0:25:41And like, anytime you find it, like, you know, you're trying to deal with, like, I ran into

0:25:46this a lot when I was trying to, you know, you're trying to style a UIKit component in

0:25:49a particular way.

0:25:51And at a certain point, at least in like every like Stack Overflow thread about how to style

0:25:56something, at some point someone will have like, now what you do is you iterate over

0:26:00all of the subviews of this view until you find a particular view with this type and

0:26:08this is apparent and like, it's like, no, you have crossed the line, my friend.

0:26:12That is like you are going to a place where you're not just sort of hacking like you are

0:26:18like just you've descended into madness because immediately that is going to break the next

0:26:24time Apple changes something deep inside that.

0:26:27And like those are the kinds of hacks where it changed, like you suddenly crossed the

0:26:31line from like, this is okay, this is, you know, just kind of part of doing business,

0:26:37this you have to kind of sometimes work around UIKit in ways that you might not like.

0:26:41But as soon as you start kind of getting, becoming so dependent on very specific behaviors,

0:26:49like the more tightly coupled you get, the far more likely your hack is to fall apart

0:26:53at some point and can often fall apart in really spectacular ways that you may or may

0:26:59not want.

0:27:01So that's something that I definitely have seen.

0:27:03It's important to develop this kind of instinct for like, you know, this isn't a good hack.

0:27:08This is not the way to implement this feature.

0:27:11And if that's what I have to do, if I have to go like spelunking down through the view

0:27:15hierarchy until I can find the view that I want to change the appearance of, like, okay,

0:27:20maybe it's just not going to be styled and that's probably okay.

0:27:24- Yeah, I mean subview diving is almost always a terrible idea.

0:27:29That's not to say I never do it.

0:27:30In fact, I do it a few places in Overcast in order to get certain behaviors.

0:27:34But there are ways to do it that are less risky than others.

0:27:36I mean, obviously like simple things like just styling tweaks, that's really easy to

0:27:40just bail out of.

0:27:41Like, you know, like if you can't find what you expect to be there in this hack, then

0:27:45just skip it and just bail out.

0:27:47Like, you know, don't, and you can always do things like make sure that you're checking

0:27:51the classes of things, using response to selector or is type of class, stuff like that, but,

0:27:57or is kind of class rather.

0:27:59You know, so there are ways you can do that are less fragile, but ultimately any kind

0:28:02of dependence on subview diving for any kind of critical feature your app is a very bad

0:28:07idea.

0:28:08And if you can avoid it at all, please avoid it.

0:28:11However, I, you know, do as I say, not as I do.

0:28:14I do subview diving.

0:28:16If I need to do subview diving, I'll do it and I'll just try to do it safely.

0:28:19And that just means you're increasing your risk of having to rework your entire UI component,

0:28:24whatever this thing is, next time a new iOS version comes out.

0:28:28And I think the last kind of hack that I was thinking about too is like so often hacks

0:28:33are the shortcuts, right?

0:28:34There are these like approaches that we're taking to a problem to do something like we

0:28:38have this big, this huge, this big amount of work that we're trying to avoid and we

0:28:42find this clever way to avoid it.

0:28:44Like it is not a good hack to do things like, to avoid things like error handling, right?

0:28:51Like it's an easy, it's an easy time saving measure to, you know, not check the error

0:28:57parameter of a callback or things like that.

0:29:00Like they're easy, which you get into these kinds of situations where I'm like, oh, I'm

0:29:04just going to quickly hack this together.

0:29:06And you know, you download the JSON blob and turn it into object and work with it.

0:29:12And assuming that JSON is there, assuming that JSON is well formed, it'll work perfectly.

0:29:17Like great, like that was a really quick time saving hack to not check any of the resulting

0:29:22values.

0:29:23But don't do that in production.

0:29:24Don't do that in something that you're going to actually, you know, ship out somewhere.

0:29:28Like that's not a, it's like that's a hack in the wrong way.

0:29:32That's when your hacking makes your app fragile and pretend, you know, and unreliable and

0:29:38not good.

0:29:40So don't do that.

0:29:41Do the other kind.

0:29:42The curious kind where it's awesome and clever and you look at it and you can show it to

0:29:45your friends and be like, isn't this sweet?

0:29:47That's the way, that's the kind you want to do.

0:29:49Thanks everybody for listening this week, and we'll talk to you next week.

0:29:52Bye.

0:29:53[BLANK_AUDIO]