I have recently been learning Node.js to build a WebSocket application with Heroku. It has been stressful. I never worked on both the client and server side of a project before. The hardest part was wrapping my head around what went where. What should I write on the server side of things, and what should I keep on the client? I began to take random guesses to what went where. I copied and pasted code back and forth between my “client.js” and “server.js” files. In the end, I had a broken application and horribly messy files. And I don’t like messy files. I decided to closed my laptop and take a breather.
I got to the point in the project where I couldn’t look at a screen anymore. My digital tools were failing me. I got up. Got some coffee. Came back to my desk and opened up my analog paper notebook and started writing. I wrote down everything I needed my application to do, and in the order it needed to do it. I was doing this to create steps for myself that I could troubleshoot piece-by-piece.
I realized when I was done that this list of steps looked a lot like a conversation. And really, it was. What had successfully done was write down the conversation that needed to happen between the client and the server. This realization helped me figure out what needed to happen on the client side, and what needed to happen on the server. Whenever I needed to create a new part of the application, I would write out this conversation first. It looks a little something like this:
I had a little fun with it here and even drew some speech bubbles.
So, if you are a Node.js n3wb like me from the client side world, I hope this tip helps. When you are beginning a Node.js app, write it out. Visualize the conversation that the client and server is having. Write it on paper, white board, post-it notes, whatever you prefer. Then tackle your application, line-by-line. Not only are you creating a to-do list for yourself, you are planning what functionality goes in what side of the application. It’s a win-win.