views:

19

answers:

1

I'm writing an application. I want various parts of it to be accessible via a single string (e.g. a URL). I see lots of different ways to implement this and wonder if anyone else is thinking about it.

For example, let's assume a web app that supports several different message boards. A URL to access the third comment in board A might be http://msg.com/A/3, and we might respond to that message at msg.com/A/3/reply. There should be no state required of a URL - I can go directly to msg.com/B/25/reply to respond to the 25th message of board B.

How would you structure your code to handle this sort of navigation? Let's assume you know how to parse the URL.

Potential problems:

  • Some interface components don't care where they are, but some need to know. The logoff button can just go to msg.com/logoff without caring where it was clicked. On the other hand, the reply button (or whatever configures the reply button) needs to know which board and message we are reading right now so it can link to the right address.

  • Ideally, the code will stay separated. This means no global string that all code can access and modify if we can help it. We could use an event bus or injection as preferable alternatives.

I don't know if this even counts as a question around here... I'm just looking for thoughts, really!

A: 

These are valid concerns, and I've spent quite a bit of time getting these issues "just right" for our product. There are a lot of other potential problems that you'll run into, and different technology stacks have different strengths when it comes to supporting those issues. Your strategy will depend heavily on exactly what you want to do with your site.

As you begin working on this, and come up with more defined questions, I think you should continue to post them here. StackOverflow is more focused on answering directed programming questions than it is on providing a forum for thoughts.

StriplingWarrior
Yeah, I was worried that this question was a bit too vague (see comment by S. Lott above). I'm struggling with the specific details right now, but there are so many that it's hard to ask specific questions. I'll just admit to myself that figuring it out will take a lot of work and get started on it. Thanks for the response!
Riley