DEV Community

Cover image for Separation of Concerns

Separation of Concerns

sentinel1909 profile image Jeff Mitchell ・2 min read

My skills with web project building are old and rusty, like 90s era old and rusty. I did coding in University, as part of my coursework in mechanical engineering. I left the coding behind and moved to an industry that didn't need those skills everyday. I noodled around with websites in the late nineties, but again, left it behind as it wasn't a demand of the day job.

Off and on, I attempted to create a blog, mostly using Wordpress, but also sometimes from scratch with HTML and CSS. Late last year, maybe because of the pandemic and the extra time I had to noodle with things, I started get serious about my own web site again.

I found an introductory article, written by Microsoft, teaching the basics of web development. This article was the first I heard the term "separation of concerns". It stuck with me and is forming the basis of my coding philosophy going forward.

So what does separation of concerns mean?

It means separating out the files comprising a project into distinct units that are isolated from each other to permit easier debugging and identification of issues...but still provide the power of working together to form a whole. In a nutshell, put .css files in a css folder, script files in a src folder, assets (like images) in a static folder, and any entry files like index.html in the top level folder. Editors like Visual Studio Code that provide a tabbed interface allow opening of files in separate tabs so that they can be easily worked with, even if they are saved in separate folders.

What else does separate of concerns achieve?

When building a web project, it allows focus on making each piece the best it can be, while maintaining the distinct relationship between components. It aids in enabling one to design a site to fail gracefully. Failing gracefully means, if any one piece is taken away, the rest will still function and convey useful information. Separation of concerns is a guard against spaghetti code, which is tough to unravel when problems in syntax or logic arise.

Never lose sight of the purpose of a creation like a web project. The purpose is to help a user do something or convey useful information to them. Implementing separation of concerns in projects will help achieve that end and make web projects both successful and easy to maintain.

Discussion (1)

arvindpdmn profile image
Arvind Padmanabhan

Can be related to SOLID design principles:

Forem Open with the Forem app