Give Me Some Space(s)!!

11 Feb 2021

Picky Picky Picky

When I first started coding, I hated formatting. It felt so stiff, ridgid, and picky. What was the point? Who cares if there’s an extra space here or there, or whether I keep my brackets on the same line? As long as my code works, right? It’s easy to say these kinds of things if it’s just you writing a small program. But as the classes got harder, or the need for group efforts and collaboration arose, that opinion really started to change–especially if you’re new to coding. Have you ever looked at a question in StackOverflow and had difficulty even picking apart the code from the person asking the question? Or have you ever looked at a teammates code and thought, “What am I even looking at?” Well, I used to be that teammate, but now I appreciate the concept of space and formatting.

There’s Art in Science and Science in Art

Of course, in this case I mean computer science! But give me a chance to explain the art concept and how it relates! In music, there’s rest notes, and normally those rest notes give emphasis to certain points in the piece. That musical piece wouldn’t even sound the same without those rests. Spaces and formatting in coding are almost exactly the same, except for your eyes! If you’re used to seeing and reading code a certain way, the same code could look totally different without the same formatting. For example, putting brackets on different lines gives emphasis that something is ending there, and putting spaces before brackets gives emphasis that something is beginning there.

Introducing a Standard

With that concept in mind, how nice would it be if everyone coded with the same format? Imagine a world where no matter who you were collaborating with, all code was neat, tidy, and read exactly the same way. Sounds nice, doesn’t it? Now imagine my surprise when I found out such a thing pretty much already exists. This semester, I was introduced to ESLint with IntelliJ. In case you’re like me and had no idea of its existence, ESLint is a coding standard that you can put into your IDE (Integrated Development Environment). It will automatically let you know anytime your code is not conforming with the ESLint standard by underlining the part in question in red, and offer you solutions to fix it! So next time you run into someone like old-me who hates formatting, introduce them to ESLint and tell them to give you some space(s)!