Code and the Coding Coders who Code it
We talk about Ruby, Rails, JavaScript, and everything in between. From tiny tips to bigger challenges we take on 3 questions a show; What are you working on? What's blocking you? What's something cool you want to share?
Code and the Coding Coders who Code it
Live at Rails World part 3
Ever wondered about the magic behind well-crafted software? Our next segment dives into the meticulous craftsmanship involved in software development within the Ruby on Rails community. We talk about the importance of thoughtful naming conventions and modularization, using examples like the "allow unauthenticated access" method from the authentication generator. We'll discuss the trade-offs between using modules and classes for encapsulation and the need for clear boundaries to avoid those pesky "mystery guests." This chapter is a deep dive into the artistry and careful planning essential to writing clean, effective code.
Ready to start your own podcast?
This show is hosted on Buzzsprout and it's awesome, not to mention a Ruby on Rails application. Let Buzzsprout know we sent you and you'll get a $20 Amazon gift card if you sign up for a paid plan, and it helps support our show.
Hello everyone, welcome to a special episode of Code and the Code Encoders who Code it live at RailsWorld. This is part three. I am joined by Andy Kroll, chris Oliver and Alan Reitelhoover. Hello, gentlemen, how are you enjoying RailsWorld so far?
Speaker 2:Good, it's really good, except for the fire alarm.
Speaker 1:Fire alarm. I heard about this 2.30 in the morning.
Speaker 2:Yeah 2.30 in the morning it had happened Tuesday or something. So some people didn't come down because they thought it was going to be another false fire alarm. I didn't know about that and then I ended up just hanging out because you're wide awake after the fire alarm until like 4 am.
Speaker 3:The definition of the alarm is that you do wake up.
Speaker 1:It's quite alarming, yeah, one might say it was just.
Speaker 2:I thought it was just very aggressive room service at first you know all right.
Speaker 1:So so, aside from uh a 2, 30 in the morning fire alarm, uh, waking you up how what's been your favorite part of rails world otherwise?
Speaker 2:just the hallway track as always, I haven't made it to any talks, as usual, but I'm here for the hallway track. Well, of course.
Speaker 1:Yeah, you know I've tried to make talks. It hasn't happened. I get like five feet. I see someone else I want to talk to. We're talking to this person now.
Speaker 2:I managed to eat lunch this year so that's the pick away over last year.
Speaker 1:The pains of being a celebrity is you don't even get lunch half the time.
Speaker 3:Celebrities are so slender right.
Speaker 4:Is that?
Speaker 3:how you stay so lean, everybody wants a dog bandy. Maintain this gun show.
Speaker 1:Well, you were running this morning, I saw I did?
Speaker 3:I felt incredibly virtuous. I went for a did? I felt incredibly virtuous, I went for a run. I said to Miles he runs. So I was like do you want to go for a run? We'll go for a run. And he's like, yeah, okay. And then at 7 o'clock when I texted him he was like I hate you. And then I said, oh, let's run to the lake. So we're right at the top of downtown where the hotels are, oh cool, and yeah, it's further to the lake than I thought it was, but we got there just as beautiful sunrise. So once we got there, past the swearing and Miles silently hating me as we, we weren't going very fast, but I think we were going slightly faster than Miles would have preferred after so many other fashions.
Speaker 1:I was going to say I don't know how many parties you guys made it to last night, but there was quite a number of things going on.
Speaker 3:Yeah, I mean the whole thing around Railsworld is great. It's got much as someone who organizes conferences. There's a real good festival vibe to this. It is intended that you don't go to all the talks, right where you go.
Speaker 1:Yeah, we were talking in the last episode about like it feels like we're just celebrating the new release, the new Rails release, like that's sort of what Rails World feels like. We're going to talk about the new Rails release? Yeah, we're going to celebrate it. There's also some talks going on at the same time. If you're interested in that kind of stuff.
Speaker 3:But otherwise party time. Yeah, absolutely yeah, it's, it's, it's catching up with people. Right, there was a photo after eileen's keynote of the ruby europe, so all the europeans who are here got on stage and I think they thought it was gonna be like three or four people. Oh my god, yeah, no, we're sort of standing there and someone at the back is going. Does the stage hold this much?
Speaker 2:human weight.
Speaker 1:This doesn't feel totally stable does canada have a fire marshal?
Speaker 4:Are we in trouble, right?
Speaker 2:now he's busy at the hotel, so no. The Rails 8 release was just fire. Yeah, super hot Bringing it back to the hotel, Alan.
Speaker 1:how have you been enjoying your conference so far?
Speaker 4:This is amazing, really amazing. Energy, a lot of new people, a lot of old friends. It's been a fun couple of days.
Speaker 1:Have you made it to any talks or are you just hallway tracking?
Speaker 4:Yeah, Eileen's was great I felt really seen, we have all those problems. It's the first talk I'm going to share with people when I get back Leadership included. Yeah, leadership included, for sure.
Speaker 1:It's a full stack problem in a way. What are you most excited for in Rails 8?
Speaker 4:Oh gosh, I have so many years ahead of me before I can get there. But I really liked the solid Q stuff. That looked really cool. Solid cache, solid cable that seems like something we could definitely take advantage of, it seems real solid.
Speaker 1:yeah, Thank you, Drew.
Speaker 3:Listen, Jason Charns isn't here.
Speaker 1:I recorded with Jason and he took care of all the jokes. And now there's. I mean I guess you could take over on jokes.
Speaker 3:No, no, I basically do swearing and my accent and you confuse that with charming and intelligent. So that's all I've got. It was quite funny. There was a bit in Eileen's talk where she said shit and I was like and the crowd sort of went. And there was a bit in Eileen's talk where she said shit and I was like and the crowd sort of went oh, and I was like when I swear on stage, I totally get away with it.
Speaker 1:It's amazing. Yeah, yeah, I'm going to start marking my podcast as explicit content, just so I don't have to filter myself anymore.
Speaker 3:Yeah, yeah, exactly, it's exhausting. We're all grown-ups here. Yeah, I mean for some definition of grown-ups.
Speaker 1:Listen, if you're a Rails dev, you've probably seen a DHH keynote, so you've heard the word fuck before yeah he is deaf.
Speaker 3:You've heard it. I mean, he squeezed it into yesterday's keynote as well.
Speaker 1:Only what eight times I actually found it.
Speaker 4:Because the last time I saw him speak I did count and that was two Portlands ago, right, and I got to 70 back in that time, 70?.
Speaker 3:He's calmed down, he's really mellowed, he really has calmed down, I quit counting at 70.
Speaker 2:I didn't have that many fingers.
Speaker 1:I had my shoes on, can't count that high.
Speaker 4:He only managed 15 this time.
Speaker 1:Okay, 15. He's getting to be an old man, yeah. It's tiring to do all that stuff it's got to be. He was jumping around all over stage too. He was very animated he was.
Speaker 3:He was Almost a dance yeah.
Speaker 1:I'm not going to lie as pumped as I am for the stuff coming out in Rails 8, I'm almost more excited about Rails 8.1. Like, just maybe because it's all new and shiny and I didn't know.
Speaker 2:I knew a lot of the stuff for 8 going into Rails 1. Yeah, it was what December was when he wrote up the list of stuff for Rails 8.
Speaker 1:Yeah.
Speaker 2:So we've been waiting since December. We've known what's coming.
Speaker 3:Yeah, the search stuff is just like. It's got that feeling of like oh yeah, of course we should have that. And it's not like oh, they should have built it already. It's like oh yeah, now it definitely feels like the time you want that, like one of the best things about Rails is the API taste and like the name it has a flavor, right, and it looks like oh yeah, that's a real railsy way of doing yeah, the 80 full-text search.
Speaker 3:That is what you want, right, and as soon as you need something more, yeah, then you reach something else. But like that's just oh yeah, of course.
Speaker 1:Yeah, I think I think the core team is excellent at really spending time marinating on naming and making sure that the name's like I. I think, chris, you have a video with Casper Tim Hanson right.
Speaker 2:Yeah.
Speaker 1:Yeah, where he like so much of that video is him talking about naming and like his rationale behind naming and like it was pretty eyeopening. Like I've always been like, hey, naming wins, naming is super important, but watching that video was like, wow, naming is. You should be spending more time naming things.
Speaker 2:A really good example of this is so before the authentication generator dropped, you would use like devise or something and you would put a before action and authenticate user for maybe your application controller. But if you needed to break out of it you would skip before action. But they just made a class method and call it allow unauthenticated access. And now that's what you see in your controllers and it's wonderfully named. There's no extra skip before action nonsense there. It's just we slapped a name on top of that. That's all the code is and it's really elegant to read and use and it's one of those examples that's like dang it, why didn't I think of that? And you might think of it more. If you're building a library, but you can do the same thing in your own application, you just never think about doing it, for whatever reason, like I don't.
Speaker 3:At least One of the things I sort of took away from Eileen's talk is all this modularization stuff. It's actually just about naming. It's about getting your concepts. Some of the problems that the modularization is trying to solve are things that are Do you know what the actual work here is? To look at these 17 models and go, do you know what that's called the wrong thing?
Speaker 3:This attribute's in the wrong place. This thing has got a bunch of stuff in it that we threw there because we were building fast. The work is what she claimed, which is do the hard work, do the hard yards of being a software engineer. Being a software engineer is like migrating stuff from one box to another. I mean, that's what we do is move that stuff around, and the solution is not more around. The solution is not more rules.
Speaker 3:The solution is more judgment, more time and that sort of thing More craftsmanship, more craftsmanship, yeah, and in all the positive sides of that.
Speaker 4:I have a pattern, a design pattern, that I like to use. It's registering classes into a factory just using the class method on the base class, and that allows me to say this class either handles something or prepares something or belongs to something, just exactly the same way you use belongs to or before action. And I think that's part of the reason why Rails is so successful is that it leverages those parts of Ruby that make things so expressive and so easy to use and the developer experience ends up so much just a pleasure to use.
Speaker 2:Yeah, yesterday I was talking to somebody and it was like you know, oftentimes you might have a model where there's like this group of three methods is related to authentication and the next three are like billing related, and then watching 37sign Signals publish Campfire and even just the Rails source code, it's like action controller base is just include these 15 modules and there's no other code in the class.
Speaker 2:And it's like if you take those three methods for billing and just move it to a module and include that module, you've now given it a name, whereas just being in the user model you've got a comment maybe that says this is the billing code, when you could extract it to another file, give it a name and then all of a sudden you have now introduced this concept to your code. That was missing. That now makes it much easier to find and rationalize about and it's more organized. And those are the little things that go a crazy long way to make something I can come back in 18 months. Forget every single thing that this app does, but jump right in, fix a bug and move right back on to whatever I was doing.
Speaker 3:It is absolutely okay to junk draw, as long as you put a label on the draw.
Speaker 1:Right, it really is like, hey, we have a bug in X. Well, okay, let me open all the files that relate to X, and I should. If you're like, hey, I have a problem with billing and you have to open I don't know user, maybe you can make that correlation, but I'd rather open a billing module or a payments module or something that feels more related. It's just less tracking down files for where something might be and more like it makes sense for it to be here, or make it Chris's problem. Or make it Chris's problem.
Speaker 4:I actually have kind of a hot take on this. When you put things in modules, you're leaving everything in that same scope as the class that you're in, and so one of the problems we see with that is there will be a method or excuse me, an instance variable defined in the controller, for example, that the module then takes reference on, but now it's a mystery guest inside the module and you don't know where it came from. Or vice versa there's a variable declared in the module and now the controller's using it. You don't know where it comes from. So my preference is always to use a class to encapsulate that stuff rather than a module. It's the same thing. I want the billing class To organize my code that way. What do?
Speaker 2:you guys think yeah, I'm generally thinking of concerns for models when I'm talking about that. But in a controller that is much messier, where you've got the action defining variables, and then if you're going to reference them in a controller concern, then it gets murky, which is why the authentication generator will put everything in the current class with current attributes, which is that pattern. That's like we're not just moving this code somewhere else, it's actually organized and can be reasoned about independently, which I think is very important. With that, if you're going to move the code, just don't just move it. Make sure it's encapsulated. This is the responsibility. It can be rationalized about independently, which helps, because otherwise you've just made it murkier by. These things are still. You've entangled them Exactly. So it's just like moving your spaghetti a little bit off to the side and you're like it's still all tangled together, hiding it in another file.
Speaker 2:Yeah, yeah, you don't want that. That makes a lot of sense.
Speaker 3:I kind of think I can make a case for both, Like sometimes you just want a big slice of spaghetti.
Speaker 2:I was going to say I love Italian.
Speaker 3:But I think again, it always boils down to this is the work of the people, right Trying to apply blanket rules.
Speaker 1:Even with myself.
Speaker 3:I find myself doing it. I'm like I always do this. I'm like, why do I always do this when I can? This could just be a method here, and sometimes I will feel the need to like, oh, I can just extract that and that's. You know, the concept. There is this, but it's like knowing it's having that feeling of when the concept deserves that special treatment rather than it just being. There's absolutely nothing wrong with a couple of methods within a class. That's the judgment that you're applying.
Speaker 2:And that's like I don't fully understand the end goal yet, so I got to put it somewhere for now and then I might figure it out six months later, actually, where it needs to be organized. But it's okay.
Speaker 3:The spaghetti is still boiling yeah. If you want to stretch and completely destroy this metaphor and then eventually to stretch and completely destroy this metaphor.
Speaker 2:let's do that, and then eventually it's underneath the chicken parmesan.
Speaker 3:And it's cold, and it moves its arm Bye.
Speaker 1:So, we only have today left because it's a two-day conference. Is there anything that you guys are hoping to do, see anyone that you haven't met yet that you're like? I want to make sure on day two at some point today?
Speaker 3:I'm going to meet. I really wish that was the case, but yesterday I was just like, is so-and-so here? And they were like, yeah, they were here all day. I saw them several times. It's just a really big conference. It is a very big conference.
Speaker 2:It is.
Speaker 3:And so for me it's just like I've been coming to these sorts of things for a while and so I know a bunch of people either well or somewhat, or say hi to or just know them from the internet, and I'm just like I've sort of let myself know that it's okay that there's going to be some folks who I like and who I've chatted with before and who I'm just not going to have the time to see or I'm just not physically going to be in the same room at the same time, because there's like five or six different areas, right. It's kind of like a you go to a music festival with your friends and then you don't see them because you get lost on the way to the bathroom.
Speaker 1:Everyone's doing something different.
Speaker 2:Chris, you got anything on your list? No, I think I'll end up in the hallway. I will aim to get lunch today again. That's my main goal.
Speaker 1:Got to eat, got to eat.
Speaker 2:Keep energized because same thing. But I always get very swamped at these, which is great because I get to meet all these people who have watched Go Rails or used Hatchbox or Jumpstart or something that I may not ever get to talk to them online or we only have a brief thing over email or something, and so it's so awesome to put faces to names and meet people in person. So I just like we'll post up in the hallway somewhere, make it five feet, end up talking to five more people, make it another five feet, and just keep doing that until, uh, until you're at the lunch table or, like last year, until the lunch is being taken away, you're just grabbing it on the way out.
Speaker 1:Yeah, yeah, alan, what do you got on your agenda?
Speaker 4:I'm really looking forward to Robbie yelling at us about TechNet. Okay.
Speaker 1:Robbie will fall on TechNet. All right, is everyone making it to the Shopify after party?
Speaker 4:Yeah, at Shopify headquarters, toby's house, it's Toby's house.
Speaker 1:Shopify headquarters Toby's house Same basic concept.
Speaker 3:We're all in.
Speaker 1:Toby's house now, yeah, I guess.
Speaker 2:Alan, are you?
Speaker 1:making it tonight. I've got a flight. Oh my God. Well, at least we're getting to see you now Getting to spend time. Anything else springing out that we want to make sure everyone who isn't here is having super FOMO about they should be here. They should be here, you're right, but it is incredibly difficult to get a ticket, so not everybody could make it All right, cool. Well, thanks for coming on. Guys Appreciate it. Enjoy. Enjoy your day, too Cool.