Best Practices--Formatting/Flow

Hi there! I’m getting back into web development after a 15+ year break. I was wondering, for those more experienced, what are your best practices when it comes writing your code.

More specifically:

  • When do you line-break as you write your code? Are there “rules” or best practices that help with organization and readability?
  • Do you code all of the HTML elements first and then move on to CSS? Do you write the CSS as you add HTML elements? What processes do you find that streamline your work?

Thanks!

  • When do you line-break as you write your code? Are there “rules” or best practices that help with organization and readability?

That really depends. Some of it is individualism, but there are some conventions. At some point, with a local IDE, you can set up a linter. Those usually come with the most commonly accepted best practices in them.

Of course, clarity is the most important thing. That and consistency. And you have to be flexible - I used to work with a guy that refused to have JS semicolons in his project, so I got used to not using them. Then I worked at a place that required them by linter, so I got used to adding them. Now I work at a place where I work on a project that uses them and a different one that doesn’t. You adjust.

I would say to be aware of it and try to improve, but don’t freak out about it. There are also online code validators/formatters that will give you a pretty standard formatting.

  • Do you code all of the HTML elements first and then move on to CSS? Do you write the CSS as you add HTML elements? What processes do you find that streamline your work?

I think you do whatever works best for you. There are projects where I build out all the HTML (or JSX in my case) and then fill in the styling (CSS) , and then the functionality. And there are projects where I work on little tiny sections to completion. I tend to lean towards the latter when things get complicated, but I’m sure I’ve done every conceivable combination at some point.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.