It’s interesting to see how my concept of a feature in my project changes with time. Meteor tends to be used for single-page, single-view apps, so I was originally going to make Playlist Me (my Stack Overflow for music recommendations app) just one page with a long, long list of questions. One of my mentors at Hack Reactor, Shawn Drost, recommended that I break the app up into separate views to make it more usable. I agreed that it would be better, but felt intimidated by the prospect of setting up a router.
Shawn pointed out to me that I didn’t need to think about adding a router, I just needed to set a few session variables and toggle them to ensure that the correct view would always be displayed. In Meteor, session variables are variables associated with the user’s session that are globally accessible with Session.get and Session.set. So splitting my one mega-view into several views went from seeming like a big change to seeming like a small change.
So I made a couple of session variables and changed them on the appropriate events. And a couple more. And then a couple more. Then I presented my app to classmates and moved on to working on a group project.
In a couple of weeks, I decided to clean up the Playlist Me code a little, so it would look better to potential employers. I found most of the code pretty reasonable, but really wasn’t happy with the routing. I thought it would be pretty hard for an outsider to understand. He would see that a couple of session variables were declared on the initialization of the app, then were changed at seemingly random points, in seemingly random combinations.
So now routing started to seem like a big change again. I found that after setting up just a few session variables, I found it unwieldly. So now I've started thinking of it as a router again, instead of as just a few session variables. I find it easier to wrap my mind around it that way, to adapt a concept I had worked with before to this problem.
Seeing routing as just a little hack was the right way to see it when I just needed to deliver the functionality (this was the day before I presented the project). But now that I want the code to really be clear, that’s no longer the best way to look at it. Now I need to think of it as a significant part of my app.
It’s just interesting how you need to think of parts of a project in different ways as the project progresses.