Do you organize your code with spaces between or just one long string

by dwhs
7 replies
My code always has a lot of space when I'm done and I want o organize it better. I know it won't effect performance but from a clean code angle. Do you add space between lines and sections or run it all together?
#code #long #organize #spaces #string
Avatar of Unregistered
  • Profile picture of the author Damien Roche
    Yeh I think good choice in spacing helps for sure. The other side is the structure of the code itself, e.g. you could extract grouped functionality into functions and that could break down the code in such a way you don't need spacing for readability.
    Signature
    >> 20 Years Full-Stack Engineer (frontend, backend, devops), Game Dev (UE5), AI Systems Dev <<
    Available for Fixed Fee Projects and Hourly Contract Work
    {{ DiscussionBoard.errors[11857372].message }}
  • Profile picture of the author EllietheMarketer
    spaces in between.

    if its one line, it gets too messy and too confusing
    {{ DiscussionBoard.errors[11857511].message }}
  • Profile picture of the author alextaylor12
    I definitely prefer spacing between sections. I usually think about it less as "adding empty lines" and more as grouping related pieces of code together. A little whitespace makes it much easier to scan, especially when you come back to the code weeks later.

    I also agree that if a section is getting huge, spacing alone isn't really the solution. That's usually a sign that the code could be split into smaller functions or components.
    {{ DiscussionBoard.errors[11857563].message }}
  • in between spaces
    {{ DiscussionBoard.errors[11858008].message }}
  • Profile picture of the author Contesthelper55
    I prefer leaving spaces between different parts and blocks of code. This makes the code easier to read, understand, and maintain. I usually group similar functions together and avoid unnecessary blank lines.
    {{ DiscussionBoard.errors[11858523].message }}
  • Profile picture of the author Conqueror777
    Yes I definitely space between the lines in order for it to look more "clean".
    {{ DiscussionBoard.errors[11858556].message }}
  • Profile picture of the author Willie Crawford
    I add spaces just to make it easier for me or others to read when troubleshooting!
    Signature

    Free PDF of "How I Built A List Of Over 1 Million" No Opt-In Required!
    Download Here!

    {{ DiscussionBoard.errors[11858627].message }}
  • Spaces while you work, and let a formatter like Prettier handle the rest so you don't have to think about it. If you want it compact on the live site, that's what minifying on build is for, no reason to write it that way.
    {{ DiscussionBoard.errors[11859547].message }}
Avatar of Unregistered

Trending Topics