Write the Code You Wish You Had


Summary

The episode explores the concept of writing beautiful code and provides a practical technique for developers to improve their coding approach. Host Jonathan discusses how beautiful code is characterized by being understandable, explainable, and testable rather than being clever or tricky with one-letter variable names or heavy indentation.

The core technique presented is asking “wouldn’t it be nice if” questions during the coding process. This approach helps developers identify pain points and opportunities for improvement in their code. For example, asking “wouldn’t it be nice if I could call a merge method on this array” or “wouldn’t it be nice if I didn’t have to write ten lines of code to accomplish this thing” provides a roadmap for writing better code.

Jonathan emphasizes adopting a mindset of writing code you love first, then making it work. This shifts the focus from immediate functionality to creating code that is maintainable and enjoyable to work with. The technique encourages developers to think about code reuse, simplification, and creating abstractions that make future work easier.

The episode includes a sponsorship segment for Bitrise, a continuous integration and delivery platform for mobile development. Jonathan mentions that the “wouldn’t it be nice if” concept may have originated with Avdi Grimm of Ruby Tapas, though he couldn’t confirm this definitively during his research.


Recommendations

People

  • Avdi Grimm — Ruby developer behind Ruby Tapas who may have originated the “wouldn’t it be nice if” concept for writing beautiful code.

Tools

  • Bitrise — Continuous integration and delivery platform for mobile development that allows teams to automate their build and deployment processes with visual workflows and numerous integrations.

Websites

  • Ruby Tapas — Website by Avdi Grimm mentioned as a potential source for the coding technique discussed in the episode.

Topic Timeline

  • 00:00:00Introduction to writing beautiful code — Jonathan introduces the episode’s topic about writing beautiful code and acknowledges that people have different opinions on what constitutes beautiful code. He explains that beautiful code is not necessarily about aesthetics but rather about being understandable, explainable, and testable. The episode aims to provide a simple technique to help developers come out of coding sessions happy with their code.
  • 00:01:43Bitrise sponsorship segment — Jonathan discusses Bitrise, the episode’s sponsor, which is a continuous integration and delivery platform for mobile development. He explains how Bitrise allows teams to automate their build and deployment processes with visual workflows, numerous integrations, and the ability to run locally with bitrise.yaml files. The platform offers over 170 integrations and supports custom scripts for any missing functionality.
  • 00:04:04The “wouldn’t it be nice if” technique — Jonathan presents the core technique for writing beautiful code: asking “wouldn’t it be nice if” questions during development. This approach helps identify pain points and opportunities for improvement in code. Examples include asking if there could be a merge method for arrays instead of writing imperative code, or if code could be reused in multiple places. This questioning provides instructions for writing better, more beautiful code.
  • 00:06:41Conclusion and subscription reminder — Jonathan concludes the episode by encouraging listeners to start asking “wouldn’t it be nice if” questions while coding. He suggests not worrying about making code work immediately, but instead writing the code you want first. He mentions that this idea may have originated with Avdi Grimm of Ruby Tapas and encourages listeners to subscribe to Developer Tea to not miss future episodes.

Episode Info

  • Podcast: Developer Tea
  • Author: Jonathan Cutrell
  • Category: Technology Business Careers Society & Culture
  • Published: 2018-05-18T09:00:00Z
  • Duration: 00:08:08

References


Podcast Info


Transcript

[00:00:00] how do you write beautiful code this is a age-old question for developers and it’s one that’s a

[00:00:10] little bit difficult to answer people have different opinions of this some people say

[00:00:16] that code is like poetry in today’s episode i’m going to give you a very simple technique

[00:00:21] to come out on the other side of your coding session happy with your code my name is jonathan

[00:00:28] and you’re listening to developer t my goal in the show is to help driven developers connect to

[00:00:32] their career purpose and to help them do better work so they can have a positive influence on the

[00:00:37] people around them and in today’s episode we are talking about writing beautiful code what is

[00:00:44] beautiful code well it kind of comes down to what you consider to be beautiful but overall most

[00:00:51] people would agree that beautiful code has nothing to do necessarily with the aesthetics of the code

[00:00:58] although that is something to be considered for example beautiful code probably is not heavily

[00:01:04] indented and so what we can do to help us define beautiful code is explain some of the things that

[00:01:10] it isn’t beautiful code doesn’t have one letter variable names beautiful code is understandable

[00:01:19] and it’s explainable as a byproduct beautiful code happens to also be easily testable beautiful

[00:01:28] code may be insightful but it’s not necessarily clever it’s not necessarily tricky so how can we

[00:01:38] arrive at this place whenever we’re writing our code we’re going to talk about that right after

[00:01:43] we talk about today’s sponsor bitrise bitrise is continuous integration and delivery for mobile

[00:01:51] for your whole team they have dozens of integrations with your favorite service so

[00:01:58] i’m writing beautiful code but i want you to imagine a beautiful continuous integration process

[00:02:04] what does that look like what buttons which you want to push and automatically have you know these

[00:02:12] five to ten steps or however many steps that you take to actually deliver your product into the

[00:02:20] app store for example wouldn’t it be nice if you could just string all of those things together

[00:02:26] those repetitive processes and then you could just string all of those things together and

[00:02:28] that you always run through well that’s exactly what you can do with bitrise and not only can you do

[00:02:34] that easily with bitrise but you can do it in a visual format you don’t have to string those

[00:02:41] services together yourself it’s not like an api system it’s a beautiful ui that allows you to

[00:02:47] piece together the parts of your continuous integration and delivery and not only that

[00:02:53] but you can share it with your whole team you can also run it on your computer and you can

[00:02:58] run it locally by using the bitrise.yaml file there’s tons of awesome integrations by the way

[00:03:04] not only does it integrate with your uh your most common services like for example if you wanted to

[00:03:11] receive a slack message you can do that of course with bitrise but you can also do lower level

[00:03:16] operations for example let’s say that you want to implement a armageddon backup plan wherever

[00:03:22] you release that you send out you also ftp up a version of your app store and you can do that

[00:03:28] as part of your bitrise workflow you can even run shell scripts so what this means is even though

[00:03:42] they have 170 integrations if for whatever reason there’s one that’s missing not only can you uh

[00:03:48] submit that to bitrise’s team but you can also integrate with whatever services you want to

[00:03:55] with your own code go and check it out

[00:03:58] spec.fm slash bitrise thank you again to bitrise for sponsoring today’s episode of developer t

[00:04:04] so we’re talking about writing beautiful code we’ve talked a little bit about what it is

[00:04:10] all right we’ve seen beautiful code and even though there is some subjective nature to this

[00:04:16] we can agree on some of the common aspects right how do we get there how can we actually write code

[00:04:24] that we love well that’s exactly

[00:04:28] the answer as it turns out so often we write code as a process of discovery we try to figure out

[00:04:37] what we need to do rather than telling the code how we want it to look so here’s a phrase i want

[00:04:44] you to adopt and this is how you’re going to write code that you love and first of all you have to

[00:04:51] adopt this this mindset that you’re going to write code that you love first and then make it work

[00:04:58] but here’s the phrase wouldn’t it be nice if it’s that simple wouldn’t it be nice if

[00:05:06] what you’ll often find is that you’ll end that question by saying wouldn’t it be nice if i could

[00:05:14] just call a merge method on this array rather than writing all the imperative code to do the

[00:05:20] merging or wouldn’t it be nice if i didn’t have to worry about all of this application state

[00:05:28] in the middle of this

[00:05:30] kind of logic code

[00:05:32] and when you start asking these questions you’re identifying

[00:05:36] ways of making a code better

[00:05:38] because yes indeed it would be nice

[00:05:41] it would be nice if

[00:05:43] there are methods

[00:05:44] to use that are doing things that you’re actually writing imperatively

[00:05:49] so these are instructions that you’re giving yourself when you say wouldn’t it be nice if

[00:05:53] you’re providing yourself instructions for writing beautiful code

[00:05:57] other examples

[00:05:58] wouldn’t it be nice if i could reuse this piece of code in five other places in this project

[00:06:05] wouldn’t it be nice if i didn’t have to write ten lines of code to accomplish this thing because i

[00:06:13] really can say it in two lines of code i can really explain it very easily but the code to do

[00:06:19] it is a lot longer wouldn’t it be nice if i didn’t have to write that code and what this does is it

[00:06:25] provides you again with a road map for code that you can use to write a code that you can use to

[00:06:28] write

[00:06:32] so that in the future when you ask that question man wouldn’t it be nice

[00:06:34] now you have the solution now you have the opportunity to write that beautiful

[00:06:38] code once again

[00:06:41] thank you so much for listening to today’s episode of developer t i hope you

[00:06:44] start asking yourself this question

[00:06:46] as you’re writing your code

[00:06:48] don’t worry so much about it working right away instead write the code

[00:06:51] that you want

[00:06:53] by the way this idea didn’t originate with me but unfortunately in my quick searching i can’t write in a Studio roll

[00:06:56] but unfortunately in my quick searching i can’t write in a Studio roll

[00:06:58] couldn’t find who it originated with although i have a hunch that it probably originated with

[00:07:04] avdi grim the rubiest behind ruby tapas i encourage you to go and check that out ruby tapas.com

[00:07:10] thank you so much for listening to today’s episode thank you again to bitrise for sponsoring today’s

[00:07:16] episode with bitrise you can use a workflow editor to piece together the perfect mobile

[00:07:24] continuous integration and delivery automation that you can share with your team go and check

[00:07:29] it out spec.fm bitrise thanks again for listening to today’s episode of developer t it’s very easy

[00:07:35] to miss out on these episodes if you are not subscribed you’re almost certainly going to miss

[00:07:42] out now if you have found any value in this episode or in previous episodes of developer t

[00:07:47] and you don’t want to miss out on that same level of value or perhaps even greater value in the

[00:07:53] future

[00:07:53] thank you

[00:07:54] i encourage you to subscribe in whatever podcasting app you use right now

[00:07:57] thank you so much for listening and until next time enjoy your tea