Prefix Namespaces for Separating Concerns

In languages like C, CSS, HTML and Javascript how might we go about applying the design concept of separation of concerns? Or even spreadsheets?

One concept that might seem primitive and yet I have found universally useful is the concept of naming things in these languages using names which start with standard prefixes in capital letters.

Keep in mind I am not a huge fan of complexity and it generally makes systems more complicated if you bring in a lot of code you do not understand.

So this technique works very well for the domain of problems that I am generally interested in, which is how can we build simple reliable systems and manage the complexity?

So by applying a naming convention such that we organize the code into buckets, each bucket gets it’s own unique prefix which is capitalized, i.e. TEM for TEMplate, PAG for PAGe handling, COR for CORe functionality:

  • We name files with this prefix

    • i.e. FOOdialog.html, UTLpopup.js, CORmain.css

  • We name code in files with the same prefix

    • i.e. function UTLpopup()

  • We locate the code in directories with the same prefix

    • So SCKloop.h goes into the SCK directory like “SCK/SCKloop.h”

Then we get some pretty compelling advantages for a team that is working on the system.

  • It becomes easy for the team to know where to find code.

    • Having a clear system of where to find code

    • Text editors especially work more easily when you can search globally for a unique name for a piece of code.

  • Debugging code becomes a lot easier

  • One eliminates the chances of random errors creeping into the system when a change in one area inadvertently impacts another part of the system.

This approach works best when you really try to limit the amount of third party you bring into your application - by third party code we code you do not understand from first principles.