[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:17.19,0:00:19.16,Default,,0000,0000,0000,,STEPHAN HAGEMANN: Thanks for coming. Dialogue: 0,0:00:19.16,0:00:21.13,Default,,0000,0000,0000,,You came to Big Rails. Dialogue: 0,0:00:21.13,0:00:23.19,Default,,0000,0000,0000,,If you did not intend to go to Big Rails. Dialogue: 0,0:00:23.19,0:00:24.89,Default,,0000,0000,0000,,My wife's actually currently in a plane, Dialogue: 0,0:00:24.89,0:00:27.63,Default,,0000,0000,0000,,and so for some reason I had to think of a\Nplane metaphor. Dialogue: 0,0:00:27.63,0:00:29.35,Default,,0000,0000,0000,,And her flight just got canceled. Dialogue: 0,0:00:29.35,0:00:30.36,Default,,0000,0000,0000,,If you did not intend to go to Big Dialogue: 0,0:00:30.36,0:00:33.14,Default,,0000,0000,0000,,Rails, which I can understand. It can be messy. Dialogue: 0,0:00:33.14,0:00:37.75,Default,,0000,0000,0000,,Better get out now, the flight might be bumpy. Dialogue: 0,0:00:37.75,0:00:39.64,Default,,0000,0000,0000,,So I want to talk about really large Rails Dialogue: 0,0:00:39.64,0:00:41.84,Default,,0000,0000,0000,,apps, and my buddy Austin suggested, a couple\Ndays Dialogue: 0,0:00:41.84,0:00:45.73,Default,,0000,0000,0000,,ago, let's use GitHub. Search for Rails. Sort\Nby Dialogue: 0,0:00:45.73,0:00:49.05,Default,,0000,0000,0000,,size. This is officially the biggest Rails\Napp you've Dialogue: 0,0:00:49.05,0:00:52.06,Default,,0000,0000,0000,,never heard of on GitHub. It's open source.\NIt Dialogue: 0,0:00:52.06,0:00:55.27,Default,,0000,0000,0000,,also only has eight models. Which is because\Nthey Dialogue: 0,0:00:55.27,0:00:56.26,Default,,0000,0000,0000,,upload all their assets. Dialogue: 0,0:00:56.26,0:00:58.05,Default,,0000,0000,0000,,It's a hundred and fifty megabytes big, and\Nthat's Dialogue: 0,0:00:58.05,0:01:01.23,Default,,0000,0000,0000,,not the kind of big I'm talking about. I Dialogue: 0,0:01:01.23,0:01:05.43,Default,,0000,0000,0000,,want to talk about component-based Rails architectures\Nand why Dialogue: 0,0:01:05.43,0:01:09.43,Default,,0000,0000,0000,,you should refactor towards them. And how\Nto do Dialogue: 0,0:01:09.43,0:01:11.77,Default,,0000,0000,0000,,that. Dialogue: 0,0:01:11.77,0:01:15.13,Default,,0000,0000,0000,,Component-based Rails architectures is a term\NI use. I Dialogue: 0,0:01:15.13,0:01:19.02,Default,,0000,0000,0000,,tag my Tweets about it as #cbra, and I'm Dialogue: 0,0:01:19.02,0:01:20.36,Default,,0000,0000,0000,,the only person in the world doing it. But Dialogue: 0,0:01:20.36,0:01:24.59,Default,,0000,0000,0000,,if you use that too, I'm certainly replying.\NAnd, Dialogue: 0,0:01:24.59,0:01:27.51,Default,,0000,0000,0000,,here's a memo for that. Dialogue: 0,0:01:27.51,0:01:32.41,Default,,0000,0000,0000,,If I can get one idea in straight off Dialogue: 0,0:01:32.41,0:01:35.72,Default,,0000,0000,0000,,the bat, then it is that this is, this Dialogue: 0,0:01:35.72,0:01:38.51,Default,,0000,0000,0000,,stuff is easy. If you can think about your Dialogue: 0,0:01:38.51,0:01:41.50,Default,,0000,0000,0000,,application by writing, by painting boxes\Nand drawing arrows Dialogue: 0,0:01:41.50,0:01:43.92,Default,,0000,0000,0000,,for things that depend on each other and how Dialogue: 0,0:01:43.92,0:01:47.04,Default,,0000,0000,0000,,they interact, then you know everything else\Nyou need Dialogue: 0,0:01:47.04,0:01:50.04,Default,,0000,0000,0000,,to know about component-based architectures\Nand you just need Dialogue: 0,0:01:50.04,0:01:52.77,Default,,0000,0000,0000,,to start doing them to what I think will Dialogue: 0,0:01:52.77,0:01:55.56,Default,,0000,0000,0000,,be improving the quality of your application\Nand the Dialogue: 0,0:01:55.56,0:01:57.68,Default,,0000,0000,0000,,quality of your code. Dialogue: 0,0:01:57.68,0:02:01.39,Default,,0000,0000,0000,,Since I called this talk refactoring towards\Ncomponent-based Rails Dialogue: 0,0:02:01.39,0:02:03.36,Default,,0000,0000,0000,,architectures, this talk assumes that you\Nall know what Dialogue: 0,0:02:03.36,0:02:06.42,Default,,0000,0000,0000,,that is. So, no. I will actually explain what Dialogue: 0,0:02:06.42,0:02:07.45,Default,,0000,0000,0000,,that is to you. You're not screwed if you Dialogue: 0,0:02:07.45,0:02:09.76,Default,,0000,0000,0000,,don't know what that is. Dialogue: 0,0:02:09.76,0:02:14.81,Default,,0000,0000,0000,,So, I started talking and actually writing\Napplications pretty Dialogue: 0,0:02:14.81,0:02:19.31,Default,,0000,0000,0000,,much exclusively in this kind of odd way,\Nso, Dialogue: 0,0:02:19.31,0:02:23.48,Default,,0000,0000,0000,,like, two, three years ago. And it, I wrote Dialogue: 0,0:02:23.48,0:02:26.09,Default,,0000,0000,0000,,this sample app that you find at this address. Dialogue: 0,0:02:26.09,0:02:29.90,Default,,0000,0000,0000,,I'm shageman with one n on GitHub. And there's Dialogue: 0,0:02:29.90,0:02:32.59,Default,,0000,0000,0000,,just the_next_big_thing sample app. Dialogue: 0,0:02:32.59,0:02:35.51,Default,,0000,0000,0000,,It does nothing. Only it shows you the structure Dialogue: 0,0:02:35.51,0:02:37.45,Default,,0000,0000,0000,,and how to hook certain things up. And let Dialogue: 0,0:02:37.45,0:02:40.06,Default,,0000,0000,0000,,me quickly go through what that means. So\Nthis Dialogue: 0,0:02:40.06,0:02:42.54,Default,,0000,0000,0000,,is the root of the project. And, as you Dialogue: 0,0:02:42.54,0:02:45.41,Default,,0000,0000,0000,,can see, it's not a Rails application. But\Nit Dialogue: 0,0:02:45.41,0:02:47.81,Default,,0000,0000,0000,,is. There's actually no particular prescribed\Nway on how Dialogue: 0,0:02:47.81,0:02:50.15,Default,,0000,0000,0000,,to do this. In many apps where I've done Dialogue: 0,0:02:50.15,0:02:51.87,Default,,0000,0000,0000,,this, the Rails application is still at the\Nroot Dialogue: 0,0:02:51.87,0:02:54.12,Default,,0000,0000,0000,,of the project. But in this particular one,\NI Dialogue: 0,0:02:54.12,0:02:56.70,Default,,0000,0000,0000,,chose the other version, where Rails moves\Ninto a Dialogue: 0,0:02:56.70,0:02:58.94,Default,,0000,0000,0000,,sub-folder and, as you can see here, so this Dialogue: 0,0:02:58.94,0:03:02.55,Default,,0000,0000,0000,,looks pretty much like Rails. But it doesn't\Nhave Dialogue: 0,0:03:02.55,0:03:05.08,Default,,0000,0000,0000,,an app folder. There, and you might be asking, Dialogue: 0,0:03:05.08,0:03:06.88,Default,,0000,0000,0000,,is there nothing happening in this app? Dialogue: 0,0:03:06.88,0:03:10.21,Default,,0000,0000,0000,,Well, there is. Here, we see there's, at least Dialogue: 0,0:03:10.21,0:03:12.24,Default,,0000,0000,0000,,one thing is mounted. There is an engine that's Dialogue: 0,0:03:12.24,0:03:18.25,Default,,0000,0000,0000,,mounted. So, Teaser::Engine. I don't know\Nif anyone has Dialogue: 0,0:03:18.25,0:03:21.26,Default,,0000,0000,0000,,ever downloaded that from RubyGems. Well,\Ndon't try. I Dialogue: 0,0:03:21.26,0:03:22.64,Default,,0000,0000,0000,,don't know what that gem would be. But I Dialogue: 0,0:03:22.64,0:03:23.99,Default,,0000,0000,0000,,didn't upload it there. Dialogue: 0,0:03:23.99,0:03:25.43,Default,,0000,0000,0000,,Let's look at the gem file to find out Dialogue: 0,0:03:25.43,0:03:28.28,Default,,0000,0000,0000,,what that gem is. So this is the, the Dialogue: 0,0:03:28.28,0:03:30.27,Default,,0000,0000,0000,,only kind of trick that you need to employ Dialogue: 0,0:03:30.27,0:03:33.70,Default,,0000,0000,0000,,when you want to write component-based architectures.\NAnd that Dialogue: 0,0:03:33.70,0:03:36.31,Default,,0000,0000,0000,,is, you use gems as not a, not as Dialogue: 0,0:03:36.31,0:03:39.06,Default,,0000,0000,0000,,a distribution mechanism, but just as a packaging\Nmechanism Dialogue: 0,0:03:39.06,0:03:41.43,Default,,0000,0000,0000,,for parts of your application. Dialogue: 0,0:03:41.43,0:03:43.40,Default,,0000,0000,0000,,You leave them in the same source tree and Dialogue: 0,0:03:43.40,0:03:45.62,Default,,0000,0000,0000,,you just reference them. And then you can\Ndo Dialogue: 0,0:03:45.62,0:03:47.70,Default,,0000,0000,0000,,everything you're used to with those things. Dialogue: 0,0:03:47.70,0:03:49.49,Default,,0000,0000,0000,,So, as you can see here, if we go Dialogue: 0,0:03:49.49,0:03:51.43,Default,,0000,0000,0000,,to the components folder, we expect to see\Na Dialogue: 0,0:03:51.43,0:03:53.49,Default,,0000,0000,0000,,teaser folder. Ah. Which we do. And there\Nis Dialogue: 0,0:03:53.49,0:03:56.02,Default,,0000,0000,0000,,an engine. So that's just a Rails. Ah, sorry. Dialogue: 0,0:03:56.02,0:03:58.70,Default,,0000,0000,0000,,A RubyGem that is pimped a little bit so Dialogue: 0,0:03:58.70,0:04:02.90,Default,,0000,0000,0000,,it has Active star. All the Actives. So Rails Dialogue: 0,0:04:02.90,0:04:05.65,Default,,0000,0000,0000,,in it. And this, indeed, now looks like an Dialogue: 0,0:04:05.65,0:04:06.67,Default,,0000,0000,0000,,application. Dialogue: 0,0:04:06.67,0:04:09.73,Default,,0000,0000,0000,,If you don't know what an engine is, it's Dialogue: 0,0:04:09.73,0:04:12.10,Default,,0000,0000,0000,,essentially Rails minus everything you need\Nto actually get Dialogue: 0,0:04:12.10,0:04:15.80,Default,,0000,0000,0000,,it booted. So, if we look in here, what Dialogue: 0,0:04:15.80,0:04:18.28,Default,,0000,0000,0000,,we can see, you know, there's a routes file Dialogue: 0,0:04:18.28,0:04:21.20,Default,,0000,0000,0000,,and this engine is doing something, right.\NThere's. It's Dialogue: 0,0:04:21.20,0:04:23.96,Default,,0000,0000,0000,,normal. Here we'll look in apps. So the controller. Dialogue: 0,0:04:23.96,0:04:26.40,Default,,0000,0000,0000,,So you can see this is namespaced under the Dialogue: 0,0:04:26.40,0:04:28.93,Default,,0000,0000,0000,,name, which is nice. But it's just, you know, Dialogue: 0,0:04:28.93,0:04:32.79,Default,,0000,0000,0000,,your ordinary controller. But, again, everything's\Nnamespaced. Dialogue: 0,0:04:32.79,0:04:38.22,Default,,0000,0000,0000,,There's assets in here. Yeah. This is pretty\Nnormal, Dialogue: 0,0:04:38.22,0:04:42.62,Default,,0000,0000,0000,,standard stuff. We even have migrations down\Nhere in Dialogue: 0,0:04:42.62,0:04:45.51,Default,,0000,0000,0000,,this engine. What else would I talk about?\NWell, Dialogue: 0,0:04:45.51,0:04:48.19,Default,,0000,0000,0000,,ah, yes. Maybe the coolest part. There's specs\Nin Dialogue: 0,0:04:48.19,0:04:49.99,Default,,0000,0000,0000,,here. I like to use rSpec. That could be Dialogue: 0,0:04:49.99,0:04:52.22,Default,,0000,0000,0000,,tests in here if you're doing this and liking Dialogue: 0,0:04:52.22,0:04:53.33,Default,,0000,0000,0000,,those better. Dialogue: 0,0:04:53.33,0:04:57.98,Default,,0000,0000,0000,,But there's, there's a spec here for this\Ncontroller Dialogue: 0,0:04:57.98,0:05:00.08,Default,,0000,0000,0000,,that I just looked at, and the cool thing Dialogue: 0,0:05:00.08,0:05:02.54,Default,,0000,0000,0000,,about that, and I don't know how to emphasize Dialogue: 0,0:05:02.54,0:05:04.00,Default,,0000,0000,0000,,it more than to come up to the front Dialogue: 0,0:05:04.00,0:05:07.34,Default,,0000,0000,0000,,of the stage and say it's very important that Dialogue: 0,0:05:07.34,0:05:09.24,Default,,0000,0000,0000,,I can run these tests, and the only thing Dialogue: 0,0:05:09.24,0:05:11.30,Default,,0000,0000,0000,,that these tests are gonna load is the code Dialogue: 0,0:05:11.30,0:05:13.60,Default,,0000,0000,0000,,from this engine, and not from all the other Dialogue: 0,0:05:13.60,0:05:16.49,Default,,0000,0000,0000,,stuff in my Big Rails application. Dialogue: 0,0:05:16.49,0:05:20.09,Default,,0000,0000,0000,,So, just by there being a spec folder in Dialogue: 0,0:05:20.09,0:05:21.80,Default,,0000,0000,0000,,here, I have a part of which I can Dialogue: 0,0:05:21.80,0:05:24.65,Default,,0000,0000,0000,,prove that it is small. Or, at least, as Dialogue: 0,0:05:24.65,0:05:26.62,Default,,0000,0000,0000,,big as only this part, and not depending on Dialogue: 0,0:05:26.62,0:05:28.71,Default,,0000,0000,0000,,anything else. Dialogue: 0,0:05:28.71,0:05:33.10,Default,,0000,0000,0000,,I, for, what I typically do, then, to kind Dialogue: 0,0:05:33.10,0:05:36.10,Default,,0000,0000,0000,,of bind these components together - and there's\Nmore Dialogue: 0,0:05:36.10,0:05:37.84,Default,,0000,0000,0000,,in this folder, as you can see. There's this Dialogue: 0,0:05:37.84,0:05:40.30,Default,,0000,0000,0000,,event counter signup and whatnot. So I write\Na Dialogue: 0,0:05:40.30,0:05:42.29,Default,,0000,0000,0000,,little script here that binds all the tests.\NAs Dialogue: 0,0:05:42.29,0:05:43.84,Default,,0000,0000,0000,,you can see there's some request specs and\Nsome Dialogue: 0,0:05:43.84,0:05:46.32,Default,,0000,0000,0000,,Jasmine specs, and if you look into the other Dialogue: 0,0:05:46.32,0:05:49.49,Default,,0000,0000,0000,,folders, you find more of these test files.\NAnd Dialogue: 0,0:05:49.49,0:05:54.17,Default,,0000,0000,0000,,then in the root. I typically put this, this Dialogue: 0,0:05:54.17,0:05:56.50,Default,,0000,0000,0000,,build script here. And what this does is loops Dialogue: 0,0:05:56.50,0:05:58.45,Default,,0000,0000,0000,,over all the folders and tries to find test Dialogue: 0,0:05:58.45,0:05:59.32,Default,,0000,0000,0000,,files and runs them. Dialogue: 0,0:05:59.32,0:06:01.33,Default,,0000,0000,0000,,So you can still run this as the app, Dialogue: 0,0:06:01.33,0:06:03.45,Default,,0000,0000,0000,,as the specs to one application. But if you Dialogue: 0,0:06:03.45,0:06:05.23,Default,,0000,0000,0000,,just change one part, you can just test that Dialogue: 0,0:06:05.23,0:06:08.70,Default,,0000,0000,0000,,one part and still be sure that it works. Dialogue: 0,0:06:08.70,0:06:11.59,Default,,0000,0000,0000,,So, now that you know what these applications\Nare, Dialogue: 0,0:06:11.59,0:06:13.19,Default,,0000,0000,0000,,you don't need to think about all those little Dialogue: 0,0:06:13.19,0:06:14.78,Default,,0000,0000,0000,,things. How to hook them up. You'll find out Dialogue: 0,0:06:14.78,0:06:16.41,Default,,0000,0000,0000,,about that when you try to do it. What's Dialogue: 0,0:06:16.41,0:06:17.63,Default,,0000,0000,0000,,important about them is that you can now talk Dialogue: 0,0:06:17.63,0:06:22.28,Default,,0000,0000,0000,,about your application as a sum of smaller\Nparts. Dialogue: 0,0:06:22.28,0:06:24.03,Default,,0000,0000,0000,,For example, the app that I just showed you Dialogue: 0,0:06:24.03,0:06:26.76,Default,,0000,0000,0000,,is a empty Rails container that mounts an\Nengine Dialogue: 0,0:06:26.76,0:06:28.26,Default,,0000,0000,0000,,that uses two other engines that I didn't\Ntalk Dialogue: 0,0:06:28.26,0:06:30.11,Default,,0000,0000,0000,,about and another gem. Dialogue: 0,0:06:30.11,0:06:31.90,Default,,0000,0000,0000,,This is a project that it recently, it o- Dialogue: 0,0:06:31.90,0:06:34.39,Default,,0000,0000,0000,,that was a tiny project, so this was Tiny Dialogue: 0,0:06:34.39,0:06:37.65,Default,,0000,0000,0000,,Rails. Empty Rails container. Two engines.\NThe one was Dialogue: 0,0:06:37.65,0:06:40.66,Default,,0000,0000,0000,,using two gems to talk to APIs, and the Dialogue: 0,0:06:40.66,0:06:45.29,Default,,0000,0000,0000,,other one was just straight-up, pretty much\Nnormal application. Dialogue: 0,0:06:45.29,0:06:47.32,Default,,0000,0000,0000,,Or this site that was a travel site. It Dialogue: 0,0:06:47.32,0:06:49.78,Default,,0000,0000,0000,,was so small, we didn't even bother to use Dialogue: 0,0:06:49.78,0:06:51.62,Default,,0000,0000,0000,,engines. We just put a couple gems in there Dialogue: 0,0:06:51.62,0:06:53.63,Default,,0000,0000,0000,,that were talking to APIs. Dialogue: 0,0:06:53.63,0:06:55.89,Default,,0000,0000,0000,,This site was a bit bigger. It started out Dialogue: 0,0:06:55.89,0:06:59.08,Default,,0000,0000,0000,,like this. We had six engines, one gem, and Dialogue: 0,0:06:59.08,0:07:01.14,Default,,0000,0000,0000,,it ended up about like this. But this is Dialogue: 0,0:07:01.14,0:07:03.15,Default,,0000,0000,0000,,a lie, because there were about twice as many Dialogue: 0,0:07:03.15,0:07:05.44,Default,,0000,0000,0000,,engines, only the other ones are abstracted\Naway for Dialogue: 0,0:07:05.44,0:07:07.06,Default,,0000,0000,0000,,clarity in this picture. As you can see, it's Dialogue: 0,0:07:07.06,0:07:08.15,Default,,0000,0000,0000,,a very clear picture. Dialogue: 0,0:07:08.15,0:07:12.21,Default,,0000,0000,0000,,Now, this looks chaotic. But the fact that\NI Dialogue: 0,0:07:12.21,0:07:14.77,Default,,0000,0000,0000,,can draw such a chaotic picture about your\Napplication, Dialogue: 0,0:07:14.77,0:07:16.68,Default,,0000,0000,0000,,but if you, if you were to draw the Dialogue: 0,0:07:16.68,0:07:19.22,Default,,0000,0000,0000,,arrows a bit straighter, you would see that\Nthe Dialogue: 0,0:07:19.22,0:07:23.01,Default,,0000,0000,0000,,dependencies all go in one direction, and\Nthat there Dialogue: 0,0:07:23.01,0:07:25.50,Default,,0000,0000,0000,,are parts that other parts are based upon,\Nright. Dialogue: 0,0:07:25.50,0:07:28.33,Default,,0000,0000,0000,,So this app is composed of parts, and it's Dialogue: 0,0:07:28.33,0:07:31.36,Default,,0000,0000,0000,,no longer a ball of mud. Dialogue: 0,0:07:31.36,0:07:32.69,Default,,0000,0000,0000,,The fact that you can see that this is Dialogue: 0,0:07:32.69,0:07:36.54,Default,,0000,0000,0000,,a complicated domain is an improvement, despite\Nthis picture Dialogue: 0,0:07:36.54,0:07:38.22,Default,,0000,0000,0000,,looking a bit weird. This picture is from\NBen Dialogue: 0,0:07:38.22,0:07:41.18,Default,,0000,0000,0000,,Smith's talk about how he architected his\NBig Rails Dialogue: 0,0:07:41.18,0:07:43.63,Default,,0000,0000,0000,,app for success, which he gave at Rocky Mountain Dialogue: 0,0:07:43.63,0:07:46.63,Default,,0000,0000,0000,,Ruby last year. And I recommend you watch\Nthat Dialogue: 0,0:07:46.63,0:07:47.55,Default,,0000,0000,0000,,talk. Dialogue: 0,0:07:47.55,0:07:51.14,Default,,0000,0000,0000,,So, if you're like, what? Now? Why would I Dialogue: 0,0:07:51.14,0:07:53.61,Default,,0000,0000,0000,,do that? As I just said. Because it helps. Dialogue: 0,0:07:53.61,0:07:57.16,Default,,0000,0000,0000,,When applications get big, I believe it's\Nfundamentally important Dialogue: 0,0:07:57.16,0:07:58.95,Default,,0000,0000,0000,,to be able to think about the parts of Dialogue: 0,0:07:58.95,0:08:04.92,Default,,0000,0000,0000,,the application independently, as much as\Npossible. Dialogue: 0,0:08:04.92,0:08:08.26,Default,,0000,0000,0000,,There's a bunch of resources that, you know.\NI've Dialogue: 0,0:08:08.26,0:08:10.43,Default,,0000,0000,0000,,given talks about this. Ben's given talks\Nabout this. Dialogue: 0,0:08:10.43,0:08:13.30,Default,,0000,0000,0000,,There's blog posts about this. And there's,\Nmost importantly, Dialogue: 0,0:08:13.30,0:08:16.73,Default,,0000,0000,0000,,that repository that I recommend you look\Nat. Dialogue: 0,0:08:16.73,0:08:22.51,Default,,0000,0000,0000,,OK. Back to Big Rails. How big? Does anyone Dialogue: 0,0:08:22.51,0:08:25.04,Default,,0000,0000,0000,,here think they're working on a big Rails\Napplication? Dialogue: 0,0:08:25.04,0:08:29.91,Default,,0000,0000,0000,,OK. That's about a third. So, I've, I think Dialogue: 0,0:08:29.91,0:08:31.59,Default,,0000,0000,0000,,I've worked on a couple, but I didn't know Dialogue: 0,0:08:31.59,0:08:33.82,Default,,0000,0000,0000,,what to show, because I work for Pivatol Labs Dialogue: 0,0:08:33.82,0:08:36.20,Default,,0000,0000,0000,,and we consult and the code is our clients', Dialogue: 0,0:08:36.20,0:08:38.51,Default,,0000,0000,0000,,so I can't show it here, so I won't. Dialogue: 0,0:08:38.51,0:08:41.13,Default,,0000,0000,0000,,But I went onto this thing called Google and Dialogue: 0,0:08:41.13,0:08:43.29,Default,,0000,0000,0000,,I searched for open source Rails apps, and\Nthere Dialogue: 0,0:08:43.29,0:08:45.35,Default,,0000,0000,0000,,they were. So these claim to be big Rails Dialogue: 0,0:08:45.35,0:08:45.94,Default,,0000,0000,0000,,apps. Dialogue: 0,0:08:45.94,0:08:50.06,Default,,0000,0000,0000,,How big, I wondered. Well, if you have, currently, Dialogue: 0,0:08:50.06,0:08:53.66,Default,,0000,0000,0000,,on your laptop, your company's code, please,\Nexecute this Dialogue: 0,0:08:53.66,0:08:57.28,Default,,0000,0000,0000,,script and Tweet the result with a #cbra hashtag, Dialogue: 0,0:08:57.28,0:08:58.93,Default,,0000,0000,0000,,cause this is just gonna open how many lines Dialogue: 0,0:08:58.93,0:09:00.63,Default,,0000,0000,0000,,of code your app has. Dialogue: 0,0:09:00.63,0:09:03.42,Default,,0000,0000,0000,,And here's the result for this list of applications. Dialogue: 0,0:09:03.42,0:09:06.58,Default,,0000,0000,0000,,So, as you can see, they're not all simi- Dialogue: 0,0:09:06.58,0:09:09.89,Default,,0000,0000,0000,,not all the same interpretation of big. So\Nwe're Dialogue: 0,0:09:09.89,0:09:13.91,Default,,0000,0000,0000,,going from about 400,000 lines of code to\Nstill Dialogue: 0,0:09:13.91,0:09:17.00,Default,,0000,0000,0000,,in the thousands. If you look at the files, Dialogue: 0,0:09:17.00,0:09:20.77,Default,,0000,0000,0000,,same picture. Thousands of files for the biggest\Napps, Dialogue: 0,0:09:20.77,0:09:24.66,Default,,0000,0000,0000,,and still hundreds for the smaller ones. Dialogue: 0,0:09:24.66,0:09:28.30,Default,,0000,0000,0000,,I'll accept that as big. And I hope you Dialogue: 0,0:09:28.30,0:09:32.91,Default,,0000,0000,0000,,will too. Ever wonder what happens to the\Ncomplexity Dialogue: 0,0:09:32.91,0:09:37.11,Default,,0000,0000,0000,,within a system as it grows? Something like\Nthis Dialogue: 0,0:09:37.11,0:09:40.39,Default,,0000,0000,0000,,happens. And maybe this is bad as that, and Dialogue: 0,0:09:40.39,0:09:43.65,Default,,0000,0000,0000,,you just can't take it anymore. Dialogue: 0,0:09:43.65,0:09:46.70,Default,,0000,0000,0000,,When you introduce structure, you fundamentally\Nchange the game. Dialogue: 0,0:09:46.70,0:09:49.90,Default,,0000,0000,0000,,Oh. I'm supposed to say, first, that this\Nis Dialogue: 0,0:09:49.90,0:09:52.86,Default,,0000,0000,0000,,because the number of interactions between\Nthe elements inside Dialogue: 0,0:09:52.86,0:09:56.37,Default,,0000,0000,0000,,the system grows somewhat like an exponential,\Nin an Dialogue: 0,0:09:56.37,0:10:00.09,Default,,0000,0000,0000,,exponential function when you add new, new\Nparts to Dialogue: 0,0:10:00.09,0:10:01.83,Default,,0000,0000,0000,,this system. Dialogue: 0,0:10:01.83,0:10:06.23,Default,,0000,0000,0000,,So it explodes in complexity. Well, what if\Nyou Dialogue: 0,0:10:06.23,0:10:11.29,Default,,0000,0000,0000,,were able to split a system and use a Dialogue: 0,0:10:11.29,0:10:14.60,Default,,0000,0000,0000,,complex web of service objects, maybe, to\Nconnect the Dialogue: 0,0:10:14.60,0:10:17.01,Default,,0000,0000,0000,,two. But you have two smaller parts that can Dialogue: 0,0:10:17.01,0:10:20.20,Default,,0000,0000,0000,,now, that are now isolated, in some way, what Dialogue: 0,0:10:20.20,0:10:21.51,Default,,0000,0000,0000,,happens to the complexity? Dialogue: 0,0:10:21.51,0:10:26.44,Default,,0000,0000,0000,,Well, turns out, it's still this, and probably\Nstill Dialogue: 0,0:10:26.44,0:10:33.44,Default,,0000,0000,0000,,that. But only half as fast. And that's good. Dialogue: 0,0:10:35.76,0:10:37.43,Default,,0000,0000,0000,,If you. I wish I could run up to Dialogue: 0,0:10:37.43,0:10:39.31,Default,,0000,0000,0000,,the slide right now. But, you see that green Dialogue: 0,0:10:39.31,0:10:42.16,Default,,0000,0000,0000,,line at the bottom? It's almost flat. Now\Nimagine Dialogue: 0,0:10:42.16,0:10:44.68,Default,,0000,0000,0000,,you could split it again, and again, and again, Dialogue: 0,0:10:44.68,0:10:46.70,Default,,0000,0000,0000,,and you always stay in this flatter part,\Nso Dialogue: 0,0:10:46.70,0:10:50.04,Default,,0000,0000,0000,,your complexity never really explodes. You\Nget those crazy Dialogue: 0,0:10:50.04,0:10:52.32,Default,,0000,0000,0000,,diagrams that I was showing earlier, but your\Ncomplexity Dialogue: 0,0:10:52.32,0:10:55.06,Default,,0000,0000,0000,,doesn't explode quite as badly. You're still\Nwriting a Dialogue: 0,0:10:55.06,0:10:57.20,Default,,0000,0000,0000,,huge app, and that's something that I'm not\Ngonna Dialogue: 0,0:10:57.20,0:11:00.01,Default,,0000,0000,0000,,discuss away. But you might be able to manage Dialogue: 0,0:11:00.01,0:11:06.48,Default,,0000,0000,0000,,it better. Dialogue: 0,0:11:06.48,0:11:11.26,Default,,0000,0000,0000,,The rich get rich and the poor get. Anyone? Dialogue: 0,0:11:11.26,0:11:17.42,Default,,0000,0000,0000,,Children. I. This is from a song from the Dialogue: 0,0:11:17.42,0:11:20.10,Default,,0000,0000,0000,,1920s, and while it's funny, the, the first\Npart Dialogue: 0,0:11:20.10,0:11:25.66,Default,,0000,0000,0000,,of this alludes to a thing called preferential\Nattachment. Dialogue: 0,0:11:25.66,0:11:29.20,Default,,0000,0000,0000,,Preferential attachment is a set of processes\Nwhere, when, Dialogue: 0,0:11:29.20,0:11:33.35,Default,,0000,0000,0000,,where, god. This is so hard to say. Where, Dialogue: 0,0:11:33.35,0:11:36.63,Default,,0000,0000,0000,,when you, where the amount of things you have, Dialogue: 0,0:11:36.63,0:11:38.23,Default,,0000,0000,0000,,whatever that might be - the thing, or you Dialogue: 0,0:11:38.23,0:11:42.90,Default,,0000,0000,0000,,- defines how much you will get. Dialogue: 0,0:11:42.90,0:11:47.83,Default,,0000,0000,0000,,So, 2006, Chris Anderson I think, wrote about\Nthe Dialogue: 0,0:11:47.83,0:11:51.42,Default,,0000,0000,0000,,long tail in, in publishing and books. And\Nhe, Dialogue: 0,0:11:51.42,0:11:53.87,Default,,0000,0000,0000,,this, this curve became very popular. He called,\NI Dialogue: 0,0:11:53.87,0:11:55.60,Default,,0000,0000,0000,,think he even called the book The Long Tail. Dialogue: 0,0:11:55.60,0:11:57.16,Default,,0000,0000,0000,,And he was concentrated on the right side\Nof Dialogue: 0,0:11:57.16,0:11:58.93,Default,,0000,0000,0000,,this tail. Dialogue: 0,0:11:58.93,0:12:00.79,Default,,0000,0000,0000,,So you have many, many small things that don't Dialogue: 0,0:12:00.79,0:12:04.54,Default,,0000,0000,0000,,get any traction. But, you know, Netflix allows\Nus Dialogue: 0,0:12:04.54,0:12:06.87,Default,,0000,0000,0000,,to view all those movies that no one wants, Dialogue: 0,0:12:06.87,0:12:08.93,Default,,0000,0000,0000,,that no one else wants to see. But there's Dialogue: 0,0:12:08.93,0:12:11.37,Default,,0000,0000,0000,,just a very few movies at the front that Dialogue: 0,0:12:11.37,0:12:14.41,Default,,0000,0000,0000,,everyone wants to see. The Blockbusters. And,\Nwhile the Dialogue: 0,0:12:14.41,0:12:17.44,Default,,0000,0000,0000,,long tail is very interesting, it's the ones\Nin Dialogue: 0,0:12:17.44,0:12:22.76,Default,,0000,0000,0000,,the front that harvest most of the benefits,\Nwell Dialogue: 0,0:12:22.76,0:12:24.70,Default,,0000,0000,0000,,I guess in the case of movies. Dialogue: 0,0:12:24.70,0:12:27.52,Default,,0000,0000,0000,,So, the green to the yellow relationship is\Nabout, Dialogue: 0,0:12:27.52,0:12:32.83,Default,,0000,0000,0000,,80% of the, the tail versus 20% is inverse Dialogue: 0,0:12:32.83,0:12:34.77,Default,,0000,0000,0000,,in the relationship to how much they have.\NSo Dialogue: 0,0:12:34.77,0:12:38.50,Default,,0000,0000,0000,,it's 20/80, 80/20. Dialogue: 0,0:12:38.50,0:12:43.21,Default,,0000,0000,0000,,And, preferential attachment, as I said, happens\Nwhen you Dialogue: 0,0:12:43.21,0:12:45.91,Default,,0000,0000,0000,,already have a lot, so you get more. And Dialogue: 0,0:12:45.91,0:12:48.35,Default,,0000,0000,0000,,I have seen so many code bases that I Dialogue: 0,0:12:48.35,0:12:50.14,Default,,0000,0000,0000,,have the feeling there's something like that\Ngoing on Dialogue: 0,0:12:50.14,0:12:52.75,Default,,0000,0000,0000,,in code. So I looked at these code bases, Dialogue: 0,0:12:52.75,0:12:56.18,Default,,0000,0000,0000,,and again, I typed in this bash script. First Dialogue: 0,0:12:56.18,0:13:00.67,Default,,0000,0000,0000,,try of course. Dialogue: 0,0:13:00.67,0:13:02.23,Default,,0000,0000,0000,,And I urge you to do the same. Now, Dialogue: 0,0:13:02.23,0:13:04.03,Default,,0000,0000,0000,,you will not be able to Tweet this, because Dialogue: 0,0:13:04.03,0:13:06.58,Default,,0000,0000,0000,,this lists all the files, all the Ruby files, Dialogue: 0,0:13:06.58,0:13:10.79,Default,,0000,0000,0000,,in your app by size. And when you do Dialogue: 0,0:13:10.79,0:13:14.73,Default,,0000,0000,0000,,that, that looks about like this for these\Napplications. Dialogue: 0,0:13:14.73,0:13:19.86,Default,,0000,0000,0000,,Now, does that not look similar? Dialogue: 0,0:13:19.86,0:13:22.04,Default,,0000,0000,0000,,There's another way of saying this, you know,\Nthe Dialogue: 0,0:13:22.04,0:13:24.70,Default,,0000,0000,0000,,rich get richer. There's a German proverb.\NI'm from Dialogue: 0,0:13:24.70,0:13:29.86,Default,,0000,0000,0000,,Germany. Hi. That proverb is that Der Teufel\Nscheißt Dialogue: 0,0:13:29.86,0:13:32.31,Default,,0000,0000,0000,,immer auf den größten Haufen. Or, the Devil\Nalways Dialogue: 0,0:13:32.31,0:13:35.56,Default,,0000,0000,0000,,shits on the biggest pile. Dialogue: 0,0:13:35.56,0:13:39.09,Default,,0000,0000,0000,,And I think something like that is going on Dialogue: 0,0:13:39.09,0:13:46.09,Default,,0000,0000,0000,,here. And which file might that be? So who Dialogue: 0,0:13:46.44,0:13:48.01,Default,,0000,0000,0000,,thinks that might be a good guess as to Dialogue: 0,0:13:48.01,0:13:51.70,Default,,0000,0000,0000,,which file that is? And, lower your, don't\Nlower Dialogue: 0,0:13:51.70,0:13:54.29,Default,,0000,0000,0000,,your hand, because it's probably actually\Nyours. I said Dialogue: 0,0:13:54.29,0:13:55.84,Default,,0000,0000,0000,,this two days ago and then the guy next Dialogue: 0,0:13:55.84,0:13:57.87,Default,,0000,0000,0000,,to me shows me his Ruby, his user file Dialogue: 0,0:13:57.87,0:14:00.16,Default,,0000,0000,0000,,and it's literally this long and I'm like,\Noh Dialogue: 0,0:14:00.16,0:14:02.17,Default,,0000,0000,0000,,god, don't do this to me. Dialogue: 0,0:14:02.17,0:14:04.55,Default,,0000,0000,0000,,But everyone else knows this problem. The\Nuser is Dialogue: 0,0:14:04.55,0:14:07.42,Default,,0000,0000,0000,,around earlier. He is important to the system,\Nso Dialogue: 0,0:14:07.42,0:14:10.95,Default,,0000,0000,0000,,he attaches, he attracts functionality. But\Nto the point Dialogue: 0,0:14:10.95,0:14:13.10,Default,,0000,0000,0000,,where I would say that is a pile of Dialogue: 0,0:14:13.10,0:14:15.31,Default,,0000,0000,0000,,shit, man. Dialogue: 0,0:14:15.31,0:14:19.57,Default,,0000,0000,0000,,And I thought that would be something else\NI Dialogue: 0,0:14:19.57,0:14:22.42,Default,,0000,0000,0000,,could find. So I looked at associations. Associations\Nare Dialogue: 0,0:14:22.42,0:14:28.51,Default,,0000,0000,0000,,another way of expressing dependencies. In\Nfact, so when, Dialogue: 0,0:14:28.51,0:14:30.25,Default,,0000,0000,0000,,I want to talk about has_manys, because I\Nfind Dialogue: 0,0:14:30.25,0:14:31.73,Default,,0000,0000,0000,,them particularly interesting. Dialogue: 0,0:14:31.73,0:14:38.73,Default,,0000,0000,0000,,So, you have something that has_many. User,\Nmaybe. So Dialogue: 0,0:14:40.36,0:14:42.13,Default,,0000,0000,0000,,since I assumed it was user, I want you Dialogue: 0,0:14:42.13,0:14:45.03,Default,,0000,0000,0000,,to read this code and, kind of reflecting\Non Dialogue: 0,0:14:45.03,0:14:48.95,Default,,0000,0000,0000,,yesterday's keynote, I find this file very\Nreadable. The Dialogue: 0,0:14:48.95,0:14:55.81,Default,,0000,0000,0000,,user has_many :cars, :flowers, :trees, :houses,\N:moods, :checks. Hopefully. Dialogue: 0,0:14:55.81,0:14:57.36,Default,,0000,0000,0000,,I think we can agree that it's very readable. Dialogue: 0,0:14:57.36,0:15:00.04,Default,,0000,0000,0000,,It makes a lot of sense and we can, Dialogue: 0,0:15:00.04,0:15:01.85,Default,,0000,0000,0000,,we can empathize with this class. Dialogue: 0,0:15:01.85,0:15:04.39,Default,,0000,0000,0000,,Have you ever wondered what's funny about\Nthis when Dialogue: 0,0:15:04.39,0:15:05.77,Default,,0000,0000,0000,,you look at the table and there is no Dialogue: 0,0:15:05.77,0:15:09.02,Default,,0000,0000,0000,,mention of :cars, :flowers, :trees, :houses,\N:moods, and :checks Dialogue: 0,0:15:09.02,0:15:13.00,Default,,0000,0000,0000,,in that table at all? You don't find it Dialogue: 0,0:15:13.00,0:15:14.78,Default,,0000,0000,0000,,funny to write that user class, but would\Nyou Dialogue: 0,0:15:14.78,0:15:16.57,Default,,0000,0000,0000,,find it funny if I wrote a color class Dialogue: 0,0:15:16.57,0:15:18.75,Default,,0000,0000,0000,,like that? Dialogue: 0,0:15:18.75,0:15:20.06,Default,,0000,0000,0000,,Why do we not write that color class? Why Dialogue: 0,0:15:20.06,0:15:22.33,Default,,0000,0000,0000,,do we always write that user class? I'll tell Dialogue: 0,0:15:22.33,0:15:24.95,Default,,0000,0000,0000,,you why. Because users are important to us,\Nand Dialogue: 0,0:15:24.95,0:15:26.97,Default,,0000,0000,0000,,we always write them first, and then we attach Dialogue: 0,0:15:26.97,0:15:30.29,Default,,0000,0000,0000,,all sorts of stuff to them that doesn't belong Dialogue: 0,0:15:30.29,0:15:34.58,Default,,0000,0000,0000,,to them. This table clearly says what belongs\Nto, Dialogue: 0,0:15:34.58,0:15:37.40,Default,,0000,0000,0000,,sorry, a user. Namely, in this case, a name Dialogue: 0,0:15:37.40,0:15:39.88,Default,,0000,0000,0000,,and a home. Dialogue: 0,0:15:39.88,0:15:42.50,Default,,0000,0000,0000,,So I've kind of gotten the opinion that we Dialogue: 0,0:15:42.50,0:15:47.33,Default,,0000,0000,0000,,shouldn't be using has_many too much. You\Ncan check, Dialogue: 0,0:15:47.33,0:15:49.22,Default,,0000,0000,0000,,and I would be very interested in the results, Dialogue: 0,0:15:49.22,0:15:52.56,Default,,0000,0000,0000,,again, so there's another gist. Please, try\Nit out Dialogue: 0,0:15:52.56,0:15:55.88,Default,,0000,0000,0000,,if you can. Dialogue: 0,0:15:55.88,0:16:02.64,Default,,0000,0000,0000,,Whoops. And guess which file is on the left? Dialogue: 0,0:16:02.64,0:16:07.17,Default,,0000,0000,0000,,Yeah. He shat on that again. The, it's the Dialogue: 0,0:16:07.17,0:16:10.74,Default,,0000,0000,0000,,user. And it's ot always actually the user.\NI Dialogue: 0,0:16:10.74,0:16:13.47,Default,,0000,0000,0000,,shouldn't be saying that. I should say, it's\Nprobably Dialogue: 0,0:16:13.47,0:16:15.81,Default,,0000,0000,0000,,always, to some extent, the user. But what's\Nyour Dialogue: 0,0:16:15.81,0:16:21.08,Default,,0000,0000,0000,,domain? If your domain is, I don't know, money? Dialogue: 0,0:16:21.08,0:16:25.73,Default,,0000,0000,0000,,Houses? Properties? I don't know. It's probably\Nthat file. Dialogue: 0,0:16:25.73,0:16:28.01,Default,,0000,0000,0000,,Whatever I just said or whatever is in your Dialogue: 0,0:16:28.01,0:16:30.30,Default,,0000,0000,0000,,name. That's that file. Dialogue: 0,0:16:30.30,0:16:32.16,Default,,0000,0000,0000,,And that attracts all the functionality. But\Nthe user Dialogue: 0,0:16:32.16,0:16:36.04,Default,,0000,0000,0000,,is typically not far behind. And, because\NI want Dialogue: 0,0:16:36.04,0:16:39.07,Default,,0000,0000,0000,,to. Yeah, I just. I think this is very Dialogue: 0,0:16:39.07,0:16:41.08,Default,,0000,0000,0000,,enlightening. So, I just opened to the project\NI Dialogue: 0,0:16:41.08,0:16:43.03,Default,,0000,0000,0000,,just showed you. I opened all the user files, Dialogue: 0,0:16:43.03,0:16:46.22,Default,,0000,0000,0000,,and I'm just gonna scroll through them, K. Dialogue: 0,0:16:46.22,0:16:53.22,Default,,0000,0000,0000,,This is not very intimidating. Eh. This is\Na Dialogue: 0,0:16:54.58,0:17:01.51,Default,,0000,0000,0000,,bit better. Ooh. I'm trying to be non-discriminatory\Nhere Dialogue: 0,0:17:01.51,0:17:08.51,Default,,0000,0000,0000,,and go the same speed Dialogue: 0,0:17:15.13,0:17:15.60,Default,,0000,0000,0000,,all the time. Ooh. Dialogue: 0,0:17:15.60,0:17:22.38,Default,,0000,0000,0000,,Oh. Oh you wait. Now, I have to speed Dialogue: 0,0:17:22.38,0:17:26.04,Default,,0000,0000,0000,,up. Dialogue: 0,0:17:26.04,0:17:29.51,Default,,0000,0000,0000,,And it's, you, this one file looks particularly\Nbad Dialogue: 0,0:17:29.51,0:17:32.79,Default,,0000,0000,0000,,maybe, but it's probably the case that these\Nuser Dialogue: 0,0:17:32.79,0:17:36.12,Default,,0000,0000,0000,,files are big to the extent that their applications Dialogue: 0,0:17:36.12,0:17:40.100,Default,,0000,0000,0000,,are big. These files just tend to do that. Dialogue: 0,0:17:40.100,0:17:44.36,Default,,0000,0000,0000,,These models just attract that. Dialogue: 0,0:17:44.36,0:17:51.36,Default,,0000,0000,0000,,So, what does that mean? Dialogue: 0,0:17:51.55,0:17:53.85,Default,,0000,0000,0000,,To recap. We have things that grow, and when Dialogue: 0,0:17:53.85,0:17:56.62,Default,,0000,0000,0000,,they grow, they get exponentially more, they\Nget more Dialogue: 0,0:17:56.62,0:17:59.88,Default,,0000,0000,0000,,complex. They get exponentially more complex.\NAnd then in Dialogue: 0,0:17:59.88,0:18:01.40,Default,,0000,0000,0000,,those things, there are certain things that\Nare, you Dialogue: 0,0:18:01.40,0:18:05.70,Default,,0000,0000,0000,,know, that are the top of the badness scale. Dialogue: 0,0:18:05.70,0:18:09.88,Default,,0000,0000,0000,,And, and those things that also depend on\Neverything Dialogue: 0,0:18:09.88,0:18:15.86,Default,,0000,0000,0000,,else in the system. Dialogue: 0,0:18:15.86,0:18:22.10,Default,,0000,0000,0000,,I don't know. I think we can do better. Dialogue: 0,0:18:22.10,0:18:24.48,Default,,0000,0000,0000,,We can try to reduce the size of the Dialogue: 0,0:18:24.48,0:18:28.21,Default,,0000,0000,0000,,parts. Maybe flatten out that curve and reduce\Nthe Dialogue: 0,0:18:28.21,0:18:34.86,Default,,0000,0000,0000,,number of dependencies in between those parts.\NSomething that Dialogue: 0,0:18:34.86,0:18:38.43,Default,,0000,0000,0000,,has helped me in doing that has been Solid, Dialogue: 0,0:18:38.43,0:18:45.16,Default,,0000,0000,0000,,the five ideas, principles. Signs, truths.\NI don't know. Dialogue: 0,0:18:45.16,0:18:45.84,Default,,0000,0000,0000,,No. Dialogue: 0,0:18:45.84,0:18:48.95,Default,,0000,0000,0000,,And especially for this problem, the Single\NResponsibility Principle. Dialogue: 0,0:18:48.95,0:18:52.86,Default,,0000,0000,0000,,I think if you just apply that as a Dialogue: 0,0:18:52.86,0:18:56.41,Default,,0000,0000,0000,,rule of thumb, as a, as a starter for Dialogue: 0,0:18:56.41,0:19:00.74,Default,,0000,0000,0000,,a conversation, it will, over time, on average,\Nimprove Dialogue: 0,0:19:00.74,0:19:04.12,Default,,0000,0000,0000,,the quality of your code. But I think there's Dialogue: 0,0:19:04.12,0:19:06.86,Default,,0000,0000,0000,,something funny going on when we discuss single\Nresponsibility. Dialogue: 0,0:19:06.86,0:19:10.100,Default,,0000,0000,0000,,Oh. Yes. What's single responsibility for?\NTo find things Dialogue: 0,0:19:10.100,0:19:17.100,Default,,0000,0000,0000,,that don't belong. Clearly it's the cat with\Nthe Dialogue: 0,0:19:18.24,0:19:21.18,Default,,0000,0000,0000,,green eyes. Dialogue: 0,0:19:21.18,0:19:27.89,Default,,0000,0000,0000,,Where, where to apply Single Responsibility\NPrinciple? If you've Dialogue: 0,0:19:27.89,0:19:29.49,Default,,0000,0000,0000,,been to any of the refactoring talks - I Dialogue: 0,0:19:29.49,0:19:31.19,Default,,0000,0000,0000,,didn't have a chance this time - but I'm Dialogue: 0,0:19:31.19,0:19:35.51,Default,,0000,0000,0000,,pretty sure you refactored some methods. We\Nlook at Dialogue: 0,0:19:35.51,0:19:37.68,Default,,0000,0000,0000,,methods, we want them to be better. We make Dialogue: 0,0:19:37.68,0:19:40.21,Default,,0000,0000,0000,,them smaller. We find what they are about\Nand Dialogue: 0,0:19:40.21,0:19:44.25,Default,,0000,0000,0000,,we give them one responsibility. Class. We\Nprobably did Dialogue: 0,0:19:44.25,0:19:46.64,Default,,0000,0000,0000,,the same, right. We look at a class, we're Dialogue: 0,0:19:46.64,0:19:48.91,Default,,0000,0000,0000,,like, oh, this does a little bit much. But Dialogue: 0,0:19:48.91,0:19:51.16,Default,,0000,0000,0000,,then we're like, OK, ActiveRecord is cool.\NI'm like, Dialogue: 0,0:19:51.16,0:19:53.74,Default,,0000,0000,0000,,allowing it to save itself and soforth. So\Nmaybe Dialogue: 0,0:19:53.74,0:19:55.52,Default,,0000,0000,0000,,that's OK. But it still kind of should be Dialogue: 0,0:19:55.52,0:19:57.80,Default,,0000,0000,0000,,about this one thing. Dialogue: 0,0:19:57.80,0:19:59.63,Default,,0000,0000,0000,,Except for user. Dialogue: 0,0:19:59.63,0:20:01.31,Default,,0000,0000,0000,,So we're, on these two levels, I think we're Dialogue: 0,0:20:01.31,0:20:06.60,Default,,0000,0000,0000,,really good. Module, and by that I mean a Dialogue: 0,0:20:06.60,0:20:08.93,Default,,0000,0000,0000,,namespace. If you use module as mixin, I get Dialogue: 0,0:20:08.93,0:20:10.77,Default,,0000,0000,0000,,like that I don't want to talk about that, Dialogue: 0,0:20:10.77,0:20:13.97,Default,,0000,0000,0000,,and that's why I continue to say namespace.\NWhy Dialogue: 0,0:20:13.97,0:20:15.72,Default,,0000,0000,0000,,do I think this about mixins? I should maybe Dialogue: 0,0:20:15.72,0:20:18.56,Default,,0000,0000,0000,,explain in one sentence. If you mixin stuff\Ninto Dialogue: 0,0:20:18.56,0:20:21.16,Default,,0000,0000,0000,,your objects, the only thing you're doing\Nis hiding Dialogue: 0,0:20:21.16,0:20:23.19,Default,,0000,0000,0000,,away the fact that you have more complexity\Nthan Dialogue: 0,0:20:23.19,0:20:24.87,Default,,0000,0000,0000,,you can bear to look at on one screen, Dialogue: 0,0:20:24.87,0:20:26.13,Default,,0000,0000,0000,,so you put it on another so you don't Dialogue: 0,0:20:26.13,0:20:29.18,Default,,0000,0000,0000,,have to see it. I would not do that. Dialogue: 0,0:20:29.18,0:20:31.12,Default,,0000,0000,0000,,I mean, I have done it. I have written Dialogue: 0,0:20:31.12,0:20:32.93,Default,,0000,0000,0000,,apps like that, and now I hate myself for Dialogue: 0,0:20:32.93,0:20:35.21,Default,,0000,0000,0000,,it. But, I want to not do it anymore. Dialogue: 0,0:20:35.21,0:20:37.75,Default,,0000,0000,0000,,So I think we shouldn't. So I use modules Dialogue: 0,0:20:37.75,0:20:42.29,Default,,0000,0000,0000,,a lot, but as namespaces, to group things\Ntogether. Dialogue: 0,0:20:42.29,0:20:44.49,Default,,0000,0000,0000,,I think you should do that. You know, look Dialogue: 0,0:20:44.49,0:20:47.45,Default,,0000,0000,0000,,at modules or namespaces and, and analyze\Nwhether they Dialogue: 0,0:20:47.45,0:20:51.97,Default,,0000,0000,0000,,have one responsibility. But have you done\Nthat lately? Dialogue: 0,0:20:51.97,0:20:54.10,Default,,0000,0000,0000,,It's harder, right? It doesn't mean a lot.\NYou Dialogue: 0,0:20:54.10,0:20:55.92,Default,,0000,0000,0000,,can, it doesn't, you know, no one cares if Dialogue: 0,0:20:55.92,0:20:57.91,Default,,0000,0000,0000,,you go across these things. You just, you\Ncan Dialogue: 0,0:20:57.91,0:21:01.79,Default,,0000,0000,0000,,load any class anyways. Dialogue: 0,0:21:01.79,0:21:05.91,Default,,0000,0000,0000,,So I think we could get better at that. Dialogue: 0,0:21:05.91,0:21:09.15,Default,,0000,0000,0000,,Let me jump a level. Application. And I think, Dialogue: 0,0:21:09.15,0:21:11.17,Default,,0000,0000,0000,,again, you should. And the fact that we have Dialogue: 0,0:21:11.17,0:21:13.22,Default,,0000,0000,0000,,this Big Rails track, and the fact that I'm Dialogue: 0,0:21:13.22,0:21:15.50,Default,,0000,0000,0000,,talking about components, but pretty much\Neveryone else is Dialogue: 0,0:21:15.50,0:21:19.20,Default,,0000,0000,0000,,talking about SOAs, shows that we are talking\Nabout, Dialogue: 0,0:21:19.20,0:21:21.88,Default,,0000,0000,0000,,what do applications mean? What does it mean\Nfor Dialogue: 0,0:21:21.88,0:21:25.42,Default,,0000,0000,0000,,an application to do something? Or, yeah.\NTo have Dialogue: 0,0:21:25.42,0:21:27.85,Default,,0000,0000,0000,,a function in, in something bigger. Dialogue: 0,0:21:27.85,0:21:30.52,Default,,0000,0000,0000,,So, I encourage you to go to all those Dialogue: 0,0:21:30.52,0:21:34.04,Default,,0000,0000,0000,,tracks and make your applications better on\Nthat level Dialogue: 0,0:21:34.04,0:21:35.89,Default,,0000,0000,0000,,as well. But I just talked to you about Dialogue: 0,0:21:35.89,0:21:37.92,Default,,0000,0000,0000,,the component, and I think that sits in the Dialogue: 0,0:21:37.92,0:21:40.75,Default,,0000,0000,0000,,middle. And in, in a certain way, the component Dialogue: 0,0:21:40.75,0:21:44.04,Default,,0000,0000,0000,,is, is an improved namespace. Because of that\Nthing Dialogue: 0,0:21:44.04,0:21:46.30,Default,,0000,0000,0000,,I said earlier, namely, I can run tests and Dialogue: 0,0:21:46.30,0:21:48.74,Default,,0000,0000,0000,,I can prove that those tests run without ever Dialogue: 0,0:21:48.74,0:21:52.40,Default,,0000,0000,0000,,touching any code that is not in that namespace. Dialogue: 0,0:21:52.40,0:21:56.80,Default,,0000,0000,0000,,So, now you can. And I urge you to Dialogue: 0,0:21:56.80,0:22:02.02,Default,,0000,0000,0000,,do it. Because the cat picture, the discussion\Nof Dialogue: 0,0:22:02.02,0:22:04.95,Default,,0000,0000,0000,,what doesn't belong. If you are in your Big Dialogue: 0,0:22:04.95,0:22:07.88,Default,,0000,0000,0000,,Rails app and you're writ- painting all those\Nclasses Dialogue: 0,0:22:07.88,0:22:10.79,Default,,0000,0000,0000,,as boxes and the dependencies they have as\Narrows, Dialogue: 0,0:22:10.79,0:22:14.70,Default,,0000,0000,0000,,first off, it's really easy to screw that\Nup. Dialogue: 0,0:22:14.70,0:22:16.39,Default,,0000,0000,0000,,Because there's no, you can't really prove\Nthat you're Dialogue: 0,0:22:16.39,0:22:18.31,Default,,0000,0000,0000,,not using another class. At least not in run Dialogue: 0,0:22:18.31,0:22:21.52,Default,,0000,0000,0000,,time with big applications. Dialogue: 0,0:22:21.52,0:22:25.79,Default,,0000,0000,0000,,So components give you an arbitrarily scalable\Nand provably Dialogue: 0,0:22:25.79,0:22:29.51,Default,,0000,0000,0000,,independent way to talk about parts of your\Napplication. Dialogue: 0,0:22:29.51,0:22:32.69,Default,,0000,0000,0000,,So I use it. Now, I said you should Dialogue: 0,0:22:32.69,0:22:36.10,Default,,0000,0000,0000,,look at SOAs, and when, if you're considering\Nrefactoring Dialogue: 0,0:22:36.10,0:22:38.39,Default,,0000,0000,0000,,your application to improve its quality and\Nto make Dialogue: 0,0:22:38.39,0:22:40.47,Default,,0000,0000,0000,,it more maintainable, I think there are a\Ncouple Dialogue: 0,0:22:40.47,0:22:45.08,Default,,0000,0000,0000,,things you should know about or consider when\Ndeciding Dialogue: 0,0:22:45.08,0:22:47.73,Default,,0000,0000,0000,,between the two. Right, you're kind of feeling\Npains Dialogue: 0,0:22:47.73,0:22:50.56,Default,,0000,0000,0000,,right now, or you're not even yet feeling\Npains. Dialogue: 0,0:22:50.56,0:22:53.25,Default,,0000,0000,0000,,Great place to be in, too. But there's a Dialogue: 0,0:22:53.25,0:22:55.53,Default,,0000,0000,0000,,couple things that are really cool about just\Nsplitting Dialogue: 0,0:22:55.53,0:22:57.38,Default,,0000,0000,0000,,up your application into these components. Dialogue: 0,0:22:57.38,0:23:01.49,Default,,0000,0000,0000,,And that is, you stick with one repo. You Dialogue: 0,0:23:01.49,0:23:04.40,Default,,0000,0000,0000,,have one test suite. But you can split it Dialogue: 0,0:23:04.40,0:23:07.90,Default,,0000,0000,0000,,up. You have, still, one deployment. You can,\Nhowever, Dialogue: 0,0:23:07.90,0:23:11.28,Default,,0000,0000,0000,,use, like, a load balancer to push traffic\Nto Dialogue: 0,0:23:11.28,0:23:13.85,Default,,0000,0000,0000,,certain parts of the application to make the\None Dialogue: 0,0:23:13.85,0:23:16.34,Default,,0000,0000,0000,,faster, the other, you know, has less of a Dialogue: 0,0:23:16.34,0:23:19.59,Default,,0000,0000,0000,,demand or, you know, you can go crazy. But Dialogue: 0,0:23:19.59,0:23:21.93,Default,,0000,0000,0000,,you don't get these additional versioning\Nconstraints of where, Dialogue: 0,0:23:21.93,0:23:23.80,Default,,0000,0000,0000,,like, if you, if you have this app and Dialogue: 0,0:23:23.80,0:23:25.52,Default,,0000,0000,0000,,it needs that app and that app doesn't have Dialogue: 0,0:23:25.52,0:23:27.62,Default,,0000,0000,0000,,the API yet, then I need to add this Dialogue: 0,0:23:27.62,0:23:30.45,Default,,0000,0000,0000,,stuff here at the same time, and I need Dialogue: 0,0:23:30.45,0:23:31.69,Default,,0000,0000,0000,,to deploy them at the same time. And if Dialogue: 0,0:23:31.69,0:23:33.80,Default,,0000,0000,0000,,I didn't do that then everything goes down. Dialogue: 0,0:23:33.80,0:23:35.21,Default,,0000,0000,0000,,You don't have that because you're still talking\Nabout Dialogue: 0,0:23:35.21,0:23:40.10,Default,,0000,0000,0000,,one application. And also, one other thing\Nthat's very Dialogue: 0,0:23:40.10,0:23:41.83,Default,,0000,0000,0000,,interesting to me, at least, is that, I never Dialogue: 0,0:23:41.83,0:23:45.10,Default,,0000,0000,0000,,know which parts I need. On this crazy graph Dialogue: 0,0:23:45.10,0:23:47.38,Default,,0000,0000,0000,,project that I just showed you, it went on Dialogue: 0,0:23:47.38,0:23:50.45,Default,,0000,0000,0000,,for about six months. And, and there were\Nthree Dialogue: 0,0:23:50.45,0:23:53.54,Default,,0000,0000,0000,,pairs on that. And at some point. Four pairs. Dialogue: 0,0:23:53.54,0:23:55.09,Default,,0000,0000,0000,,And at some point, there was always one pair Dialogue: 0,0:23:55.09,0:23:57.94,Default,,0000,0000,0000,,refactoring something. And they created, I\Nthink there were Dialogue: 0,0:23:57.94,0:24:00.18,Default,,0000,0000,0000,,a couple weeks where they created basically\Na component Dialogue: 0,0:24:00.18,0:24:02.52,Default,,0000,0000,0000,,a day. But they also removed a component. Dialogue: 0,0:24:02.52,0:24:03.93,Default,,0000,0000,0000,,Try to do that with a SOA. Try to Dialogue: 0,0:24:03.93,0:24:06.35,Default,,0000,0000,0000,,move that stuff around quickly. You can do\Na Dialogue: 0,0:24:06.35,0:24:09.67,Default,,0000,0000,0000,,SOA, I think, when you, when you're sure you Dialogue: 0,0:24:09.67,0:24:12.41,Default,,0000,0000,0000,,need pieces. But when you're playing around\Nwith parts Dialogue: 0,0:24:12.41,0:24:14.53,Default,,0000,0000,0000,,of your application and you, you want to just Dialogue: 0,0:24:14.53,0:24:16.01,Default,,0000,0000,0000,,structure it, and you want to still be able Dialogue: 0,0:24:16.01,0:24:18.84,Default,,0000,0000,0000,,to move a part from one to the other, Dialogue: 0,0:24:18.84,0:24:21.37,Default,,0000,0000,0000,,SOA is a bit heavy. Dialogue: 0,0:24:21.37,0:24:26.69,Default,,0000,0000,0000,,Within a SOA, you can still think about your Dialogue: 0,0:24:26.69,0:24:29.93,Default,,0000,0000,0000,,applications as being built of these components.\NThere's, you Dialogue: 0,0:24:29.93,0:24:34.13,Default,,0000,0000,0000,,know, nothing is exclusive there. Just do\Nboth. Dialogue: 0,0:24:34.13,0:24:41.13,Default,,0000,0000,0000,,So, I've now spent about, most of my time Dialogue: 0,0:24:41.50,0:24:44.30,Default,,0000,0000,0000,,telling you why you should refactor towards\Nthis. But Dialogue: 0,0:24:44.30,0:24:45.84,Default,,0000,0000,0000,,I haven't done what I said in my title Dialogue: 0,0:24:45.84,0:24:47.31,Default,,0000,0000,0000,,I would do, namely tell you how to refactor Dialogue: 0,0:24:47.31,0:24:51.47,Default,,0000,0000,0000,,towards it. I'm sorry about that. But I gave Dialogue: 0,0:24:51.47,0:24:55.43,Default,,0000,0000,0000,,you this idea, right. And you all believed\Nme. Dialogue: 0,0:24:55.43,0:24:58.66,Default,,0000,0000,0000,,This is easy. Dialogue: 0,0:24:58.66,0:25:01.77,Default,,0000,0000,0000,,Today's day of the, International Day of the\NBook. Dialogue: 0,0:25:01.77,0:25:06.87,Default,,0000,0000,0000,,I looked in these books. Refactoring to Patterns.\NRefactoring. Dialogue: 0,0:25:06.87,0:25:10.85,Default,,0000,0000,0000,,Awesome books. But they don't talk about this\Neither. Dialogue: 0,0:25:10.85,0:25:12.38,Default,,0000,0000,0000,,And I think the reason is that this stuff Dialogue: 0,0:25:12.38,0:25:15.43,Default,,0000,0000,0000,,is not very important in other languages.\NIn Java, Dialogue: 0,0:25:15.43,0:25:17.76,Default,,0000,0000,0000,,you do packages every day and you have implicit Dialogue: 0,0:25:17.76,0:25:20.07,Default,,0000,0000,0000,,imports. In Go, you do that. Other languages\Ndo Dialogue: 0,0:25:20.07,0:25:22.86,Default,,0000,0000,0000,,not have this problem, because other languages\Ndo not Dialogue: 0,0:25:22.86,0:25:25.58,Default,,0000,0000,0000,,allow for this kind of freedom and openness\Nthat Dialogue: 0,0:25:25.58,0:25:31.21,Default,,0000,0000,0000,,we've gotten because we do Ruby. Dialogue: 0,0:25:31.21,0:25:35.26,Default,,0000,0000,0000,,So, I call these two refactorings, teasing\Nout an Dialogue: 0,0:25:35.26,0:25:39.09,Default,,0000,0000,0000,,app component and extracting a functional\Ncomponent. And the Dialogue: 0,0:25:39.09,0:25:40.26,Default,,0000,0000,0000,,reason I don't want to spend much time on Dialogue: 0,0:25:40.26,0:25:42.05,Default,,0000,0000,0000,,it is because it's actually very simple to\Ndo Dialogue: 0,0:25:42.05,0:25:46.43,Default,,0000,0000,0000,,it. The devil's just in the details. Dialogue: 0,0:25:46.43,0:25:48.97,Default,,0000,0000,0000,,And there is no book about this. But I'm Dialogue: 0,0:25:48.97,0:25:52.22,Default,,0000,0000,0000,,trying to write one. And if you, I don't Dialogue: 0,0:25:52.22,0:25:54.47,Default,,0000,0000,0000,,know, show, if you're interested in this,\Nsend a Dialogue: 0,0:25:54.47,0:25:56.44,Default,,0000,0000,0000,,message there and I might be more inclined\Nto Dialogue: 0,0:25:56.44,0:25:58.06,Default,,0000,0000,0000,,actually sit down. Dialogue: 0,0:25:58.06,0:26:01.79,Default,,0000,0000,0000,,All right. But to the first one - teasing Dialogue: 0,0:26:01.79,0:26:08.73,Default,,0000,0000,0000,,out an app component. So, step zero. Got tests? Dialogue: 0,0:26:08.73,0:26:11.10,Default,,0000,0000,0000,,If, if you don't have tests, I wouldn't move Dialogue: 0,0:26:11.10,0:26:13.59,Default,,0000,0000,0000,,as much code as we're about to move. I Dialogue: 0,0:26:13.59,0:26:16.71,Default,,0000,0000,0000,,mean, virtually. But, you should add some\Ntests around Dialogue: 0,0:26:16.71,0:26:19.19,Default,,0000,0000,0000,,the stuff that you want to extract. Dialogue: 0,0:26:19.19,0:26:21.48,Default,,0000,0000,0000,,And then you, for the app component. So that's Dialogue: 0,0:26:21.48,0:26:24.54,Default,,0000,0000,0000,,this teaser thing we looked at. So we're,\Na Dialogue: 0,0:26:24.54,0:26:27.12,Default,,0000,0000,0000,,component of your application, where you almost\Nthing, this Dialogue: 0,0:26:27.12,0:26:30.07,Default,,0000,0000,0000,,could be its own application, maybe. So you\Nlook Dialogue: 0,0:26:30.07,0:26:35.14,Default,,0000,0000,0000,,for this vertical. Views, controllers, models.\NYou find that Dialogue: 0,0:26:35.14,0:26:38.15,Default,,0000,0000,0000,,vertical that makes sense on its own and you Dialogue: 0,0:26:38.15,0:26:39.48,Default,,0000,0000,0000,,namespace it. Dialogue: 0,0:26:39.48,0:26:42.06,Default,,0000,0000,0000,,A funny thing happens when you just namespace\Nit. Dialogue: 0,0:26:42.06,0:26:44.61,Default,,0000,0000,0000,,Suddenly, the things in there. Well, first\Noff, what's Dialogue: 0,0:26:44.61,0:26:46.37,Default,,0000,0000,0000,,awful about it is you have to rename all Dialogue: 0,0:26:46.37,0:26:49.48,Default,,0000,0000,0000,,your tables. OK. But that aside, you suddenly\Nstart Dialogue: 0,0:26:49.48,0:26:53.50,Default,,0000,0000,0000,,seeing what's actually in your vertical and\Nwhat's not. Dialogue: 0,0:26:53.50,0:26:55.38,Default,,0000,0000,0000,,You could actually put colon colon in front\Nof Dialogue: 0,0:26:55.38,0:26:56.85,Default,,0000,0000,0000,,everything else that's not, and you would\Nget a Dialogue: 0,0:26:56.85,0:26:59.72,Default,,0000,0000,0000,,really easy view parsing or, or way of seeing Dialogue: 0,0:26:59.72,0:27:02.27,Default,,0000,0000,0000,,in your files what's not in your vertical. Dialogue: 0,0:27:02.27,0:27:06.20,Default,,0000,0000,0000,,Those are your external dependencies to, an\Nexternal to Dialogue: 0,0:27:06.20,0:27:08.26,Default,,0000,0000,0000,,the app. So when you do this at first, Dialogue: 0,0:27:08.26,0:27:09.93,Default,,0000,0000,0000,,you're apps gonna be unhappy. So please make\Nyour Dialogue: 0,0:27:09.93,0:27:12.89,Default,,0000,0000,0000,,tests green. And to do that, you will need Dialogue: 0,0:27:12.89,0:27:15.34,Default,,0000,0000,0000,,to find other parts that you didn't know you Dialogue: 0,0:27:15.34,0:27:19.90,Default,,0000,0000,0000,,depended upon, and you move them into what's\Ngonna Dialogue: 0,0:27:19.90,0:27:25.38,Default,,0000,0000,0000,,be the component. Into this vertical. Dialogue: 0,0:27:25.38,0:27:28.60,Default,,0000,0000,0000,,And when you got this vertical green, you\Nextract Dialogue: 0,0:27:28.60,0:27:34.14,Default,,0000,0000,0000,,it into an engine. Extracting into an engine\Nis Dialogue: 0,0:27:34.14,0:27:37.52,Default,,0000,0000,0000,,rails plugin new component dash dash full,\Ndash dash Dialogue: 0,0:27:37.52,0:27:39.66,Default,,0000,0000,0000,,mountable. In most cases. Dialogue: 0,0:27:39.66,0:27:41.24,Default,,0000,0000,0000,,It doesn't matter. Dialogue: 0,0:27:41.24,0:27:48.24,Default,,0000,0000,0000,,And step three, profit. Now, most of the time, Dialogue: 0,0:27:49.46,0:27:52.20,Default,,0000,0000,0000,,this vertical will not be as easy to find Dialogue: 0,0:27:52.20,0:27:55.33,Default,,0000,0000,0000,,as I just pretended it would be. And that's Dialogue: 0,0:27:55.33,0:28:01.52,Default,,0000,0000,0000,,because of, you guessed it, user. Right? The\Nuser Dialogue: 0,0:28:01.52,0:28:05.42,Default,,0000,0000,0000,,is probably somewhere, and other things as\Nwell, are Dialogue: 0,0:28:05.42,0:28:08.59,Default,,0000,0000,0000,,used somewhere, are needed somewhere, but\Ndon't really belong Dialogue: 0,0:28:08.59,0:28:09.94,Default,,0000,0000,0000,,to this verticle. Dialogue: 0,0:28:09.94,0:28:13.12,Default,,0000,0000,0000,,And what I've found is when you refactor towards Dialogue: 0,0:28:13.12,0:28:14.98,Default,,0000,0000,0000,,this, if you abstract. If you, if you're coming Dialogue: 0,0:28:14.98,0:28:17.65,Default,,0000,0000,0000,,from one big piece, if you want to abstract Dialogue: 0,0:28:17.65,0:28:20.57,Default,,0000,0000,0000,,one thing, you're gonna abstract two. The\None thing Dialogue: 0,0:28:20.57,0:28:24.20,Default,,0000,0000,0000,,you wanted and the common stuff. But please\Ndo Dialogue: 0,0:28:24.20,0:28:26.34,Default,,0000,0000,0000,,not call that stuff common, because that's\Njust gonna Dialogue: 0,0:28:26.34,0:28:28.22,Default,,0000,0000,0000,,be another pile of shit that you can attach Dialogue: 0,0:28:28.22,0:28:30.17,Default,,0000,0000,0000,,stuff to. Call it something else. Call it\Nuser Dialogue: 0,0:28:30.17,0:28:34.21,Default,,0000,0000,0000,,if you have to. Dialogue: 0,0:28:34.21,0:28:36.05,Default,,0000,0000,0000,,So this special case is not a special case. Dialogue: 0,0:28:36.05,0:28:38.46,Default,,0000,0000,0000,,I think this is, of course there is lots Dialogue: 0,0:28:38.46,0:28:40.53,Default,,0000,0000,0000,,of meat in how to do this and where Dialogue: 0,0:28:40.53,0:28:43.03,Default,,0000,0000,0000,,you get hung up on certain gem dependencies\Nand Dialogue: 0,0:28:43.03,0:28:45.21,Default,,0000,0000,0000,,engines not doing it exactly the way that\NRails Dialogue: 0,0:28:45.21,0:28:48.02,Default,,0000,0000,0000,,does it and blah, blah, blah. But essentially\Nthis Dialogue: 0,0:28:48.02,0:28:52.14,Default,,0000,0000,0000,,is it. Dialogue: 0,0:28:52.14,0:28:55.11,Default,,0000,0000,0000,,The other side to this is, is, something even Dialogue: 0,0:28:55.11,0:29:01.84,Default,,0000,0000,0000,,more interesting. It's abstracting functional\Ncomponents. Now your app Dialogue: 0,0:29:01.84,0:29:05.47,Default,,0000,0000,0000,,is round, suddenly. I don't know why. Again,\Ngot Dialogue: 0,0:29:05.47,0:29:08.76,Default,,0000,0000,0000,,tests? Let's start there. Dialogue: 0,0:29:08.76,0:29:11.20,Default,,0000,0000,0000,,So you find a functional component, and yes,\NI Dialogue: 0,0:29:11.20,0:29:14.03,Default,,0000,0000,0000,,made that much smaller than that verticle.\NBecause typically Dialogue: 0,0:29:14.03,0:29:16.24,Default,,0000,0000,0000,,you find a piece that is really, really separate. Dialogue: 0,0:29:16.24,0:29:20.37,Default,,0000,0000,0000,,A very special functionality. Maybe even something\Nmathematically a Dialogue: 0,0:29:20.37,0:29:23.84,Default,,0000,0000,0000,,function. In and out. Some processing. You\Nfind that Dialogue: 0,0:29:23.84,0:29:27.91,Default,,0000,0000,0000,,and you create a gem. Dialogue: 0,0:29:27.91,0:29:30.11,Default,,0000,0000,0000,,And you move the tests in there as well, Dialogue: 0,0:29:30.11,0:29:31.96,Default,,0000,0000,0000,,and your gem is, when you run those tests, Dialogue: 0,0:29:31.96,0:29:34.44,Default,,0000,0000,0000,,the gem's gonna be unhappy, because of all\Nthose Dialogue: 0,0:29:34.44,0:29:38.22,Default,,0000,0000,0000,,dependencies that you didn't see coming. So,\Nyou take Dialogue: 0,0:29:38.22,0:29:42.42,Default,,0000,0000,0000,,all those and you move them in. And you Dialogue: 0,0:29:42.42,0:29:44.54,Default,,0000,0000,0000,,make your tests happy. Dialogue: 0,0:29:44.54,0:29:47.49,Default,,0000,0000,0000,,Well, and now you require that gem in the Dialogue: 0,0:29:47.49,0:29:50.35,Default,,0000,0000,0000,,main app, and your main app is totally unhappy. Dialogue: 0,0:29:50.35,0:29:51.72,Default,,0000,0000,0000,,Because it doesn't know how to talk to that Dialogue: 0,0:29:51.72,0:29:57.95,Default,,0000,0000,0000,,gem anymore. And if there were any ActiveRecord\Ndependencies, Dialogue: 0,0:29:57.95,0:30:00.69,Default,,0000,0000,0000,,or other dependencies on, on stuff that came\Nfrom Dialogue: 0,0:30:00.69,0:30:03.66,Default,,0000,0000,0000,,Rails, I would urge you to try and keep Dialogue: 0,0:30:03.66,0:30:06.14,Default,,0000,0000,0000,,that out of, of these kinds of gems, because Dialogue: 0,0:30:06.14,0:30:08.20,Default,,0000,0000,0000,,it just adds such a huge surface area and Dialogue: 0,0:30:08.20,0:30:11.34,Default,,0000,0000,0000,,stuff that could happen, could be done and\Ncould Dialogue: 0,0:30:11.34,0:30:12.14,Default,,0000,0000,0000,,go wrong. Dialogue: 0,0:30:12.14,0:30:15.30,Default,,0000,0000,0000,,I, I would urge you to find these connections, Dialogue: 0,0:30:15.30,0:30:20.63,Default,,0000,0000,0000,,these, the shims, maybe. Call them ports and\Nadapters. Dialogue: 0,0:30:20.63,0:30:23.42,Default,,0000,0000,0000,,And move them in the app closer to the Dialogue: 0,0:30:23.42,0:30:25.80,Default,,0000,0000,0000,,surface area of this gem, so that you can Dialogue: 0,0:30:25.80,0:30:28.31,Default,,0000,0000,0000,,do the processing of whatever that is there,\Nand Dialogue: 0,0:30:28.31,0:30:30.97,Default,,0000,0000,0000,,that talks to the gem and makes it work Dialogue: 0,0:30:30.97,0:30:33.58,Default,,0000,0000,0000,,again. So now the app is happy. And you Dialogue: 0,0:30:33.58,0:30:37.08,Default,,0000,0000,0000,,got this weird kind of lump on the side. Dialogue: 0,0:30:37.08,0:30:38.35,Default,,0000,0000,0000,,But that's a good thing. Dialogue: 0,0:30:38.35,0:30:40.74,Default,,0000,0000,0000,,In, in one of the books, actually I think Dialogue: 0,0:30:40.74,0:30:42.91,Default,,0000,0000,0000,,it's Eric Evans, it's called Bound to Context.\NNow Dialogue: 0,0:30:42.91,0:30:45.44,Default,,0000,0000,0000,,you have a thing that is only relevant for Dialogue: 0,0:30:45.44,0:30:49.64,Default,,0000,0000,0000,,a context. But that's how you take from that, Dialogue: 0,0:30:49.64,0:30:52.45,Default,,0000,0000,0000,,from that curve that has the huge left side. Dialogue: 0,0:30:52.45,0:30:54.15,Default,,0000,0000,0000,,That's how you chip away at the top and Dialogue: 0,0:30:54.15,0:30:56.53,Default,,0000,0000,0000,,put it somewhere at the end. Because this\Nthing, Dialogue: 0,0:30:56.53,0:30:59.15,Default,,0000,0000,0000,,in a bound context, it only has one meaning. Dialogue: 0,0:30:59.15,0:31:00.60,Default,,0000,0000,0000,,And that's why it's gonna be smaller. Dialogue: 0,0:31:00.60,0:31:07.60,Default,,0000,0000,0000,,So, step three. Profit. Dialogue: 0,0:31:07.82,0:31:14.30,Default,,0000,0000,0000,,I hope that made sense. And I know. It Dialogue: 0,0:31:14.30,0:31:16.65,Default,,0000,0000,0000,,doesn't work that easily. It's not five steps.\NIt Dialogue: 0,0:31:16.65,0:31:19.61,Default,,0000,0000,0000,,can take weeks. The first time we tried this, Dialogue: 0,0:31:19.61,0:31:22.09,Default,,0000,0000,0000,,it took three attempts and four weeks in one Dialogue: 0,0:31:22.09,0:31:24.76,Default,,0000,0000,0000,,app that we wanted to split into two. And Dialogue: 0,0:31:24.76,0:31:26.89,Default,,0000,0000,0000,,we ended up with three, and now I think Dialogue: 0,0:31:26.89,0:31:30.17,Default,,0000,0000,0000,,it's about ten. But, trust me, you can get Dialogue: 0,0:31:30.17,0:31:30.82,Default,,0000,0000,0000,,there. Dialogue: 0,0:31:30.82,0:31:35.57,Default,,0000,0000,0000,,And I kind of felt challenged by Far- by Dialogue: 0,0:31:35.57,0:31:40.49,Default,,0000,0000,0000,,Farrah's keynote yesterday. So, I will help.\NIf you Dialogue: 0,0:31:40.49,0:31:42.33,Default,,0000,0000,0000,,want to attempt this, and you don't find the Dialogue: 0,0:31:42.33,0:31:44.28,Default,,0000,0000,0000,,resources and any of those links that I gave Dialogue: 0,0:31:44.28,0:31:47.09,Default,,0000,0000,0000,,you, Tweet at me, talk to me, send me Dialogue: 0,0:31:47.09,0:31:49.67,Default,,0000,0000,0000,,an email. I'll respond to all of them. Maybe Dialogue: 0,0:31:49.67,0:31:53.39,Default,,0000,0000,0000,,publicly so it helps others, too. I just think Dialogue: 0,0:31:53.39,0:31:55.77,Default,,0000,0000,0000,,this is a great way to structure applications\Nand Dialogue: 0,0:31:55.77,0:31:58.27,Default,,0000,0000,0000,,to make them better, and that's why I just Dialogue: 0,0:31:58.27,0:32:00.77,Default,,0000,0000,0000,,will help. Dialogue: 0,0:32:00.77,0:32:04.33,Default,,0000,0000,0000,,So don't let these guys ruin your day. Make Dialogue: 0,0:32:04.33,0:32:06.61,Default,,0000,0000,0000,,friends with the #cbra, and thanks for your\Nattention.