Tuesday, December 8, 2015

I Love Javascript but...

I love Javascript. It is the language of my choice.  I can do everything with it.  I love NodeJS as well.

But, I hate when I open a project in an editor with Javascript.  Browser-side and server-side code, they all have .js extensions - eek!

It is easy to confuse your IDE with multitudes of Javascript files that are named the same but are in completely different interfaces of your application.

How to solve?  Perhaps adding some silly extra extension to your frontend files like:

clients.interaction.js

But who wants to write that extra suffix?  Sure you could make it shorter like "ui" or whatever. We do have EJS which heralds the distinguished .ejs extension but it still looks very close to .js.  Perhaps:

clients.view.ejs

Now onto backend, we like our short file names, Clients maps to clients.js in a controller, right? Again, if we kept the nomenclature throughout the app, we might have "clients.js" for a:
  • UI processed Javascript file
  • UI template Javascript file
  • Controller file
Oh yeah, forgot to mention the potential model:

clients.model.js

I just think that adding all those "dots" is silly for application but an IDE that lists all files can easily make you lose your place, even if you have navigated into the correct folder.  Therefore, we might need to think about a standardized convention - or do we?  Or is this ask stupid and petty?  Not sure, but I do find myself opening one file just to close it after I realize I am in the wrong folder.

We could go with the acclaimed CamelCase model and that would suffice but enforcing case-sensitivity on files sucks for Windows users.  It would look pretty though:

  • ClientInteraction.js
  • ClientView.ejs
  • ClientController.js
  • ClientModel.js
Any ideas are welcome for managing modern NodeJS applications.

1 comment: