Joseph Ravenwolfe's Notes
junk-drawer-programming

junk-drawer-programming

I know that you didn't do this. But I figure just for educational purposes, it's worth pointing out that this file is written in a style that I have heard referred to as "junk drawer programming". :joy: But I need to admit, it's kind of hard for me to find all the blog posts about this from so many years ago.

In a nutshell, I would say that junk drawer programming is whenever a team ends up with a file that they just keep throwing more code into without much thought being put into it.

A heuristic I use to identify this is unnecessary comments, and unnecessary new lines. Spotting these as a heuristic measure works for me because:

  • Unnecessary comments usually mean that the code was not Self-Documenting Code™
  • Unnecessary new lines are an indication that the programmer isn't practicing good architecture (e.g. they are not writing enough functions and modules, so they are reaching for the Return key on the keyboard to "break up" the code)

In this file, we see that it is being written as a large junk drawer of Firebase functionality. And to make up for the lack of good architecture, we are seeing swaths of code sectioned off with a comment like /// *** THIS SECTION *** and a use of new lines to further "break it apart".

I think it would be a really fun exercise for you to eventually refactor this into "good architecture". If that doesn't sound exciting, I'd recommend Katrina Owen's talk called "Therapeutic Refactoring". She'll sell the idea much better than I probably will. :smile:

Referred in


If you think this note resonated, be it positive or negative, send me a direct message on Twitter or an email and we can talk.