Routing and State (The AngularJS Discussions)

Posted by Peter Kellner on March 26, 2015 · 1 min read
Ad: Learn Modern JavaScript on YouTube (3 Hours & Free)

I’m a big fan of the Adventures in Angular podcasts.  At a recent podcast that happened at ng-conf in Salt Lake City, there was a lively discussion around the topic of routing and URL’s.  Specifically, one side of the discussion was that a URL defines a state of an application.  The other side said that is not true.

Personally, I think it’s ridiculous to think that a URL can define that state of applications.  My first proof is that there is a huge amount of discussion around it.  If it was clear and true, there would not need to be discussions about it.

I believe that URL’s are simply pointers to places in web sites.  That’s it.  Any more than will breed confusion.  The most trivial example is that a web page is different when the user is authenticated (logged in) versus not.  That by itself should close the discussion.

On a more constructive note, I think it’s reasonable to map application states to URLs. For Example, their might be three states while viewing an employee record on a web site, all at the same URL. The states might be as follows:

  • State 1:  Not Logged In (show error)
  • State 2: Logged in as Employee
  • State 3: Logged in as Manager

All three states would show different data and allow for different interactions.  All different, all on the same URL.

Bottom line, we as engineers should not get confused with things we do for convenience and start thinking that there is some science behind that.  Recognize it for what it is.