Hello and welcome to another episode of the Bike Shed, a podcast from your friends that thought about developing great software. I'm Ajis later. And I'm Joel Kinville, and today we're here to share a bit of what we've learned along the way. So Joel, what's new in your world? We are recording this a week before Rails world, and I'm speaking at that conference.
So that's the big thing coming up. The way this conference has been structured is a little bit different than a lot of other Ruby conferences I've been at, in that the slides will not be playing for my laptop. So I'm not showing up and plugging in my laptop and doing things. Instead, they have their own system and I will just be given a clicker, and I'm going to stand on stage and hit next and they already have all the content. Okay.
Because of that, they needed me to submit my slides a week in advance. Wow. And I don't know about you, when you've given your talks, I don't typically have my talk ready to go a week before the event. Yeah, that would be troublesome for the way that I end up working. How have you handled this?
Poorly? I got the slides in. I've been trying out a slightly different workflow where my traditional workflow is very time-intensive, and it relies on me just throwing some stuff together in a deck really poorly, and then rehearsing the talk and finding the place I don't like, and then cutting, adding new content for re-inflating it, giving the talk again and just doing that dozens of times, until I get to a place where I like the flow and it works pretty well. That's very time-intensive. What I've been doing this time has been maybe doing a more traditional approach where I put a lot of time working with the outline, and then really sort of went back and forth just on the outline.
That was where my iteration happened. And then taking something that was mostly good and turning that into a slide deck. Okay. Yeah, I think I would probably agree or have said before really digging into it that that would be what I would consider the more traditional approach. That feels like what I assume the majority of people do.
I wonder if that's actually true or not, but how has that approach changed the outcome? It's interesting because for me, I often tie the visual storytelling with the content, and those two overlap, but they don't align one to one. So I might know, hey, I want to make this point, I want to make this point, I want to make this point. That will definitely not align one to one of the slides, but even the how I tell it, what parts are going to need for transitions, what parts are going to need focus, can really sort of take a point and inflate it over four or five slides, or take two or three points in compressing the bone to one slide.
There's a lot of pacing stuff, so that the outline of the contents of what I want to share, versus the narrative beats and the narrative arcs, need some transformation. And I typically sort of done all that at once as more of a holistic process, and this time I split it out a little bit more. Right. Has that made you sort of more or less dependent on the slides or more or less in sync with those? Have you had to separate that out a little bit more?
Like what has that been conceptually for that storytelling? Something I often struggle with is finding what I call the soul of the talk, something that really holds the talk together and gives it the oomph that's more than just words on a page. And there's a little bit of that that lives in both the slides for a storytelling aspect of it and in the point you're trying to make. And oftentimes I start out with an idea and I want this broad idea to come across to people, and then I start writing it out and it's like writing a textbook. You're just like, I'm going to break this down into like five categories each of which subdivide into five more categories, and now I'm going to walk you through that tree.
And that is boring, and people are just going to walk away from that from just like a haze of terminology. But maybe within that there are really important things I want to say, and I want people to come away with them, but maybe they don't all tie together in just sort of one cohesive takeaway. And so that I think at the outline level helped me to really focus on that aspect of it without even having to think about the more visual, how am I going to share these ideas or how am I going to make this point? I really want to make, how is it going to come across? Now there is some of the soul that does live in the sort of the execution of how I'm going to speak it, how I'm going to display this idea visually, because I'm not just putting text light up for text light. I've got a variety of different techniques I use to show things visually, but
the figuring out the soul sometimes, I get sort of so wound up in the more holistic approach that it's just sort of rehearsal after rehearsal, I'm like, there's something that doesn't quite feel right. What if I cut this? What if I cut that? And I think the more outline focus approach maybe helped me converge a little bit faster? With the caveat that I'm working with, you know, end of one at this point. It's interesting that you say that the outline approach helped you
converge on that faster, because usually the outline step for me, it's not sort of generative in the way that does that help me find the soul or I usually refer to it as just like, what is this talk actually about? That sort of comes later, I think a lot of the similar way that you were describing there that you'd have kind of this structure and then just the iteration and the holistic approach just kind of draws it out. Yeah, so I'm not going to get Reelsworld, but if you are at Reelsworld, I think just speaking of course not you, you are going to be at Reelsworld, but to anybody listening. If you're going to be there or you were there, depending on when this comes out, it'd be really cool to go say hi to Joel and we're looking forward to seeing the recording, so you know how if it even does feel different, now that I have this little insight about the approach that you took.
How about you? What's been new in your world? Yeah, my current team, my current project team is starting to, well, we've been in the process a little bit of planning out what the next big chunk of feature work is going to be for our little group and as we're going through deciding potential implementations, also what are the constraints that we're working with all of these different things, boil it down. It is essentially that we need to interact with this API that we don't have any control over and we are going to have to take some steps that feel a little drastic in order to layer on top some features that are going to be useful in our application that the API doesn't provide.
Things like having to call it early and store some data on our end and these different things that feel a little icky, feel like maybe what we wouldn't want to do because then we're having different sources of truth and layering out a lot of complexity, right? Jobs that are going to be running overnight, all of these different things and that's all well and good but the kind of extra hitch here is that this is an API that is worked on by another team at the same company. So it's not that it's completely out of our control, it's not out of our control from our team standpoint and it is a different application essentially, as far as we're concerned, not as far as the user is concerned but it is a different application, right? As far as we're concerned and so there are some things that are just sort of harder to get over for me, maybe sort of emotionally or spiritually that we are having to layer on this extra complexity and these things that we are going to have to be mitigating the maintenance of the systems that we're putting in place in order to overlay these features that would
be completely wiped off the table if we could just add a search to this endpoint but we were just not able to communicate or we couldn't stack priorities up in the right way to make that something that was going to be on this other team's plate anytime soon, just competing priorities and it didn't work out in our favor this time and so it's added a little twist of trying to think about implementations that are lightweight enough so that hopefully this search feature does get added that we can just wipe it all away and have the better thing, right? And implementing something that is maintainable and we can work with it well enough that we don't then become so entrenched on this one approach that we can't then remove it later for something that is 100% across the board which is better and easier and less complex and so that is something that I either haven't really done or haven't had to do in a while that just adds this extra set of questions to everything that we're doing and when everything comes up it's like okay but is that just going to make a lot of trouble later?
Is that going to be something that like are we creating so much of an extra subsystem that we're no longer going to be able to take it away because we're now building on top of on top of on top of the thing that we already have, right? So that just the search feature isn't going to obviously these needs and everything so yeah I don't have any kind of like wisdom to like have followed these through or anything like that but those are the kinds of thoughts that are going on in my head recently. It reminds me a little bit of the idea of like an adapter pattern or a shim that you might use when you're migrating off an old system onto a new one where you sort of create something that mimics the old API that implements the new behavior such that at some point you can switch to the new one and then just drop the shim and everything keeps working the way it used to.
It sounds like you're kind of trying to do that where you want to have a stable API that you talk to whether that's an actual like each PAPI or it's you know some Ruby client thing that walls this off and at some point a little bit of internal swapover but everything else stays the same. Yeah I think that layer is kind of a pretty common pattern right? It's that sort of thing that you want to be able to do. The interesting bit here is that there is some like data that we're copying over and creating like data structures within our system. That's the part that doesn't feel as like comfortable maybe or like has a little bit more of a different sort of approach or pattern to it.
Are you thinking that those things still stay hidden behind the adapter barrier or you think that those are actually visible to your application so that you might couple yourself to them? I think in this first step they will be like nicely encapsulated. We can just kind of think of it as another source of the same thing but there's always the kind of worry or want to protect against it's not necessarily a scope creep but like feature creep that we are going to start implementing things because we have this data here rather than implementing things which are just part of this other data source right that we're accessing maybe in a different way but we're going to start depending on having that data as opposed to just reaching it in a different path. Right so you'll have to whatever that like interface barrier is that simulates what you would have next year when the other team builds their thing. You have to be really disciplined about not allowing your application logic across that. Right exactly yeah and keeping that interface barrier
relatively similar to what the other team is likely to build. Right which is. You could build that application and be like oh we also love this API and we also love this API and now you build a really rich adapter and when they implement their end it's only going to have a quarter of the features and you can't drop it. Right I say I'm optimistic but it's you know we can't see into the future right what features what needs are going to come up and so on top of the usual planning for we can't see the future so changeability always being in front of mind in everything. It's yes specific different kinds of change abilities in this use case that are interesting interesting in that like grubble grubble interesting kind of way. On the other hand you're doing a lot of validation work
for the other team right like you can go to them in 12 months and say all right now you're ready to build that search feature here's exactly the shape we need and here are the other side features that we discover that we will need as your number one consumer. That's true. I see yeah and hopefully we'll be able to get those across in a way that maybe we weren't able to communicate this number. So it sounds like there's going to be some amount of like programmer discipline involved in sort of making sure you don't cross that boundary in some ways like that. I don't know about you but I always it's something that prickles in the back of my neck a little bit every time I hear a programmer discipline because I don't trust it much rather some form of automated system and there's all sorts of automated tools and things that can happen. I'm pretty interested in our things that fall under
static analysis. Sure. Yeah. And I don't know something like that could help in this particular situation but I'm curious about your thoughts on static analysis tools in general. Like you whenever there's something that the solution is just basically willpower.
It's not really something that you can depend on right and so having something that could tap on the shoulder every time that you're about to cross that boundary would be fantastic. I think yeah if that's things like linters different processes that can run in CI I've cooked up some fairly interesting I guess I guess it would be static analysis tools just to fail a build if we do something that passed us didn't want us to be able to do right. I think they're really invaluable not only because of having so many competing priorities in your head something slipping through even with the best of intentions at all times but makeups of teams change like documentation doesn't get read or any number of reasons that a team working all together on the same goal and in the same like context all the way through can just still absolutely these things will fall through the cracks and so yeah having something that can not depend on willpower but just be checking the actual ones and zeros of the
strings that you have sent into GitHub. Like I mentioned the word static in front of static analysis the whole world of all sorts of different sorts of analysis that you can do. How would you describe static analysis what makes it different than other forms of analysis we do? I think and no idea how close to any sort of like formal definition or whatever this is but it's when the code is at rest it's not being executed it's something else looking at like the sleeping code and doing its own kind of thinking over top of that whether it's actually parsing out an AST and looking at it in that way or even if it's just running red jacks as and that kind of thing.
You can get surprisingly far with a regular expression. You really can. Like you don't have to be like a you know compiler genius to be able to benefit from static analysis. Yeah that's and that's for sure the first any kind of static analysis rules or anything that I've ever written were just regular expressions to do something. I don't know if it was RuboCop or if it was the S-Lint or something like that but it's just like I want this specific pattern of characters to throw up a red flag and using a regular expression was the first way that I got into setting up those kind of automated boundaries for myself.
Just to give a clearer example of what you're talking about. A static analysis tool would be something like a Lintrut like RuboCop or ES Lint which just take in a file look at its characters and then give you a report or a pass fail or something like that as opposed to a test suite which will it doesn't just look at the raw characters it will load and execute that code. So test suite not static Lintr is static. Okay yeah I first split second there I was thinking like wait are you saying that test suites are static okay no gotcha. Yeah I'm trying to give like clear examples of both categories. Absolutely. Do you have a favorite static analysis tool is there
something that you I don't know always have running reach for a lot that maybe isn't the standard off the shelf RuboCop? I've got perhaps a hot take here as a Rubiest. I'm a huge fan of type systems. That said I've not done a whole lot with like Sorbet or RBS in Ruby but in TypeScript in Elm other languages type systems can be really nice at catching all sorts of code without errors or edge cases without having to execute the code which is really nice and one of the most classic being on handled null errors. All those oh you didn't think about the edge case here but if it's nil and I don't know how many times I have shipped on to find method on null null class to production a type system catch that I mean hopefully you're running on your local machine but at the very least it'll catch it on CI and that just removes a whole class of problem that can make it out of production. So if you haven't experimented with the kind of like Sorbet RBS these sort of Ruby
implementations of typing in the language is there anything that in the Ruby ecosystem that gives you some of that feeling or is that just sort of lost to Ruby without these new approaches? I probably say my technique that most closely resembles typing is not a static analysis technique and that is just leaning into more structural invariance. So instead of taking just passing raw hashes around maybe creating a little data object and setting fields on it and that has a preset set of fields and it's just much harder to accidentally have different data than you expected as a way with a hash is just like who knows right it could be anything and if you think you know you are probably in for some missing key errors or some null errors sometime very soon in your future.
Please know. So I always like to do if I'm dealing with like the external API and I get a JSON hash I very quickly try to transform it into some kind of either a regular Ruby class or maybe little data object and that approximates a little bit what I would get from from a checker. Okay so if you can do a little bit of this approximation what then are some static analysis tools that you use in the Ruby world if you don't get this class of static analysis what are some of the things that you reach for? Something that can be interesting are ones that don't necessarily give you sort of line by line things but instead might give you some form of score. So a lot of the classic let's say complexity analysis tools that can run on Ruby code so something like a vlog or or something like that you could even say something like a code climate which will give you a score by my file or by method. Those are all things that give you some insights about your code without
necessarily executing it. Then it's up to you as an individual and as a team how you want to handle those things. Those things are often proxies for a thing you care about and so you get a high complexity score. Does that mean the method is bad? Maybe there might be some more context that goes into that and you might need to make a decision around it. Oftentimes you might have some really
really high score that you're like this is a cutoff. Anything above that is almost certainly not just a bible but most code probably wants to be significantly beyond whatever your max cap is or you can bring that cap much lower down and have people then have to find clever workarounds to that. I've definitely had been on projects where CI would break for a pretty aggressive complexity score and then having to work my way around it. Have you found in situations like that where the complexity score is quite aggressive that those clever workarounds and things often end up making things much more complex than part of understanding. Sometimes when you're fighting with your tool and you're just trying to satisfy it rather than solve the actual problem, I think then you're sort of losing some of the benefit. Sometimes you want the ability to override the
problem is that sometimes the tool is right and the thing that you first came up with at the work around was like satisfies the tool but it's worse but there is a solution that can satisfy both conditions. Satisfies the tool and also is good for the broader principle and if you can't find it, sometimes that's on you. That's not always the case. Sometimes you really are sort of stuck between doing a dumb thing to satisfy the tool versus overriding the tool and so that's why I'm a little bit skeptical of setting these hard thresholds that will fail a build too aggressively while also sometimes it's good to push the team a little bit and say look can we do better? We got a big code smell or red flag or whatever you want to call it. There's something that's not quite right here.
Is there a better approach we could think of? Do you think there is a place then for using these tools in a way that wouldn't fail a build but just are something to give you a little bit of information, something that you might run yourself or locally that could give you a little bit of that insight without creating a rule that you can't move forward with. So you're talking something like a warnings mode? Yeah. Have you ever run like executed Ruby with warnings turned on?
No, not really. I'm aware of it and I think I've run it on small things but no. I guess technically that's not static analysis because it is actually executing the code. Sure. Technically maybe it happens that a compile phase inside the interpreter or whatever, which might technically make it. Now we're splitting hairs.
Yeah. Not really the dynamic that we're kind of focusing on right now. The I think sad things that oftentimes development teams will just ignore warnings mode. Yes for the Ruby runtime but tools that emit warnings tend to just get silenced. On a smaller sort of conscientious team that can be really good.
On a broader team where you're trying to keep some consistency especially if it's a team where not everyone is as motivated for high quality and there are people who are just rushing things through and just give me a thumbs up on that PR that's silenced this thing and like to ship it. There might be some need for some stronger pushback. I think there's also something to be said too that when there are rules or things that are more aggressive than a warnings mode but sort of require certain standards of practices, right? There's something to be said for once a team gets large enough to not be able to all kind of puddle and talk about the way they want to use the language or their tools to just create an amount of somewhat arbitrary consistency, right? That there are oftentimes a lot of different ways to do something that are all perfectly valid and none of the trade-offs hurt the particular use case but it is worthwhile to kind of all stay on the same page about how to write a particular approach.
And they're going to apply to sort of broader level of things too, not just like style. Things like standard RB or standard rails often a lot of the rules that they'll have in place are yeah not necessarily going to have they're not stylistic but they're also not going to have an incredibly dangerous impact or something they're not preventing you from something super dangerous. Some of them do but some of it is just foot guns that have happened once to somebody that became a rule that maybe don't actually even cross into a dangerous territory all that often but but there they are. One of my favorite sessions at a RailsConf was when Justin Serals ran a it was a talk but it was a session where we voted on the initial rules for standard rails because he had a test double or behind standard RB and so we got to go through the suggested rules and their different options and things like that and vote on it as the people in the room that were there and that was a really interesting exercise especially because just very opinionated and so every time that we chose a rule
implementation that he wasn't in favor of himself he would run an ad for test double which was very fun and got a lot of groans after a certain point and so but we held to it in some places where the room disagreed with him so that's funny. A practice that I'll sometimes do is I like to default to something that's a little bit safer with the ability to override and I'll do this sometimes for Rubocop and I know there's a school of thought that says that your lender should be a thing that is always true and should not be over writable and there's a whole class of things which I think that's probably correct for but there are other classes of things that I want to prevent statically and say 80% of the time or 90% of the time you should not do this but occasionally this should be permitted and so what I want at that point is for you to have to do the work and you're going to write that Rubocop disable comment and then I want a justification written in the comment above the code when you say hey we're overriding Rubocop here normally we don't want to do this here's why
that's okay here and if you can write that justification you're probably already in a good place for having a good reason to be able to ship for it even without somebody else reviewing it if you're just like have this annoying the building and just want to stop production slap on a skip thing because it'd be like it'd be weird to try to fix this yeah it's like throwing a bunch of any's into your type system right it's yeah well so honestly any in a TypeScript is an opt-out it's the equivalent of the Rubocop skip our disable comment that you do for Rubocop yeah I'm much closer for type systems to say that you should not have the ability to opt-out or we should make it really really difficult to opt-out because the way that TypeScript is the really just finding consistency in your program and so if you opt out of the type system at one point in your code anything downstream of it is now a kind of poisoned right so it's not just a local effect so yeah type systems I'm much more skeptical the bar is a lot higher for what I would want to break out of a type system versus a linter especially if you're writing custom linter rules for things that are not always
necessarily going to be true I think that's more acceptable and I can't allow you to write those more ambitious linter rules that are specific to your project and say hey we try to not do this thing right is that something that there should be a lint rule for that you have to put a comment above the disable comment I thought you've gone recursive on me I feel like that's maybe a PR to Rubocop that you should be able to turn that that cop on that rule right right I kind of like that this is yeah this is maybe I might have just nerd sniped myself how do you feel about disabling rules yeah I think I feel fairly similar that there should be a way to opt out especially if yeah sometimes there sometimes there is the need to do something kind of icky and so like taking it even one step further right to like you should be able to justify this and kind of think it through I'm even going further sometimes even hopefully more rare than the justification opt out sometimes there's like no this is just what we need to do and I don't love it but this is how it this is what
we're gonna have to do in order to make this thing even just work and so I do think it should be there but again assigning random metrics to things is not I don't super love but if there is a way to track like hotspots for overriding or like are there certain rules that could over written a lot maybe statically analyze the static analysis nudging and things like that it should send up a red flag it shouldn't be just a matter of course disabling something you should require a little bit of extra explain yourself or a little bit of extra like buy in from the team because you are essentially taking on maybe just my new little amount but a little bit of a debt a practice that I started doing is anytime I'm doing code review if there's a comment that I'm like I would like to not have to leave this comment again I'll start thinking about is there a way that I can turn this into a little interval or some other way of catching it automatically you know some of those might be something more dynamic right is there a form of testing that I could add to the app that will help a developer catch this early because I might not catch it on the XPR and even if I do I'd rather not have to
spend my time catching the same thing all the time right I worked on a project a while back where we had a pretty bad outage due to a use of the delete all method in rails and for those more familiar this is a command that bypasses any form of validation or callbacks or any of those and just goes straight to the database and it executes on an active record relation and someone would combo that I think with an unscope that I think was hoping to just remove some conditions and realize it had removed everything and it detruncated a table for us we were able to restore from backups but that's the kind of thing where you're like that should not have made it to production and it went on up to PR and it went back on like how did this make it through and it is and I was able to trace it back here's the PR that introduced it and like here's the developer who did it all that like all right who reviewed this thing it was me I gave it up on that PR how did I miss that
but also I would like to not have that sort of thing just fall through and be up to me to be like super vigilant all the time 100% I introduced a Rubocop that said like you're not allowed to use delete all in almost all situations or other things you want to do right I'm not saying we're gonna ban it 100% but our default case should not be using delete all if you really want to use it you have a good justification write that comment in the disable and it's up to your reviewer on the PR but now the review on the PR gets a chance to see like big flashing red flag hey I'm doing something dangerous here I'm overriding the system play pay close attention to this and you're much more likely to catch the I guess it's not a bug it's a I guess just the flaw in the code right there yeah I think that touches on a lot that you're even yourself at an earlier later date is you know another developer that is aligned obviously with the way that you think and the way that you want to write code but that these things can still fall through because there's just so much going on you can't expect maybe not even willpower but just omnipotence right and so backing yourself up
with with these static tools and kind of automating a little bit of the thinking that has to go on when you're doing these I really like that also just from an incremental automation sort of standpoint it's like I've left this comment three times now what can I do to never leave this comment again I really love it from that aspect as well that's a really great um that's sort of trying to push linters beyond just style style can be applied more universally once you're starting to get into these like bigger this is the risky thing we want to default to not doing it sometimes we can those sorts of things I think do require you to have the ability to over it yeah I think my you know my personal stance is that like style should just be in a formatter like if that's if that's all it is it should just take care of itself and like maybe I don't prefer the way that it aligns dots from other goals or whatever but just completely take that out of having to think about it at all so here's another form of static analysis I want to run by you um security scanners yeah I honestly don't have a ton of experience I don't think besides um having them run on my code
by other other folks I think it's another yeah it's another something that is a signal that can be kind of like learned from an add a lot of value but also sometimes I find has had a lot of like false positives maybe and so like that ability to opt out when it's like no I've thought about this more than the automated tool and like thanks for the rep thanks for the flag I checked into it it's like this isn't actually thing and yeah so I think it's not something that I would want to have like as part of the CI build maybe or at least not the ones that I've had experience with let's put it that way I guess there's a variety of types of scanners you might have some that are like looking at all your code or your diff or something like that there are also some that are more specialized on something just like your external dependencies might scan like your gem file or you know I package JSON or something that I'd be like you know what this gem file has some known vulnerabilities sure yeah I think that's something like a break man or yeah no that's true I didn't even think about that as part of the category we're talking about but depending about there all the time always always has our back right to a more or less annoying extent
sometimes but I'm always like that's not something that I'm gonna be doing is combing through a gem file and that's that's something that is perfect for automation right is like looking through like matching up a CD list or something especially for like transitive dependencies absolutely yeah that is that is something that I automate that away because it probably never existed in the first place before it was on me it's not really we're probably at the point where we should wrap up but I do want to give a sort of brief taste of something that I am going to be talking about in my talk next week at Rails world absolutely and that is looping the output of some of these automated static analysis tools into your LOM I'm sort of contrasting the what I call the prompt and pray approach where you yeah you you just like try to write the perfect prompt and hope it writes good code and it's usually slop versus something that will maybe do that run an static analysis tool and then loop that back into the LOM and it's able to iterate on its output until by the time it hands something over to you as a developer the bar on what you're looking at is significantly higher it might still need some significant revision but it's not just absolute
bottom of the barrel the way it would be after just the first output and so really leaning into how are all these like dumb things that because you know I were talking about comments I'd rather not leave on PRs for other developers and other developers already start from a pretty good baseline and LLM like if I have to give it like all these like comments like this is bad this is bad I would like to not have to say that so that same logic but just sort of take into a more scalable approach of like what are the things I would like to not have to correct the LOM on and have itself correct on and it seems like a tools like this could potentially have a better effect on the output of the LLM than say just being part of a prompt or something like that yes yes so that's a big part of the talk is effectively saying don't just put this in your clawed MD like clawed MD should not be your style guide right we have an automated deterministic tool that can find style issues consistently just loop that back in and don't let it be done until it has satisfied Rubocop and in fact some things in Rubocop are auto correctable let the deterministic
program do its thing automatically and then for the things that can't just give the errors back to clawed or whatever your agent is and it will then fix them and that's a much better workflow than just putting a bunch of rules into your clawed MD and being like I hope it follows them maybe yeah let's not completely give it up on deterministic systems here no no in fact I think LLM's become much better when in many ways there's sort of wrappers around really strong deterministic tools so that's one of the big points of the talk that's really cool yeah now I'm even more looking forward to see them putting this up on that sort of little teaser shall we wrap up sure