I like to keep things clean in my applications. Especially the URLs, however I have found that my routes table has grown to 62 routes, which includes all the paging, and altering of views. This seems like a lot to me. How many rules to do you have for
your application?
I wish there were better ways to classify and break down the rules. Because when you get past 10 you probably have to start gaming your order inorder to tweak performance.
Believe it or not all these URL's are processed through the same two Action Methods. However the Pairs are what kills me What I define by a pair are the following:
If the variable in each of these is not present then grouping from above should not be present. Or if the upcoming flag is on or off decides to display the popular ideas or the upcoming ideas that haven't become popular yet. Also all these pairs can be
combined in any combination. The actual URL logic would look like this
Everything in the square brackets are optional to the URL, but if the variable in the square bracket is present then the whole part of the square bracket should be present. I obviously could do this with just the variables but then I would have a ton of
magic numbers in my URL. And this:
Then how would I differentiate between a group_name and a category_name. This problem accounts for 24 routes instead of a possible 1 actual route.
Also the 62 number is probably actually around 28 where 12 of them are the routes I just described, if I take out all the paging additions that I had to put in.
If anybody as a solution for me, that doesn't involve the magic numbers I would love to hear it. But this is the kind of Route table that a production application is going to have to deal with, if they don't want magic numbers in their URL.
I have ~30 right now, its a pretty complicated setup but will be playing with it again and seeing if I can reduce it somewhat without increasing overal complexity of the readability. Its large though so that I can support www.domain.com/Username
Its hard to tell what you could do without seeing your actual routing code, but giving up your "pairs" and setting up defaults would help . "Pages/3" Is very unneccessary instead of just /1....99+. With the way the rest of the URL is currently formatted
right now it wouldnt be very obvious what "7/2" is, I agree. So instead of days/1, days/7, days/30, days/356, and whatever else you may do - which isnt immediatly obvious what they are either without visiting your site and seeing the links I would change that
"pair" to a more obvious Parameter "Today", "ThisWeek", "ThisMonth", "ThisYear" with a default when none supplied or some such would also help.
That should remove a few routes, but you're going to be left with quite a large table still because of the nested structure you want.
Which would complicate things further, because groups and categories would get mixed up, because both are just strings that can occupy the same space. Same with days and pages. The days right now are static, but they could be dynamic in the future, with
a slider dictating the range that is brought back. Also once you visit the site the URL starts to make sense in a contextual way. So I am not really concerned about the users who see my URL for the first time and don't understand it, because very few people
are going to use that reasoning to not click on it and follow it.
IMO the nested structure is important, I just feel that working with routes could be easier. Since each of my URL's that aren't above start with pretty standard stuff like.
I am probably going to make a custom handler that skips a whole set of rules, and fast forwards to the set of rules that start with say "account". So that the processor doesn't have to evaluate rules that I know aren't going to work.
Marked as answer by nberardi on Jun 16, 2008 08:52 PM
What you might consider instead is a catchall route and handle in code the splitting of pairs, that might work fairly well for you as your using the same action method for pretty much every request anyway.
nberardi
Star
11233 Points
2352 Posts
How many rules do you have in your route table?
May 30, 2008 03:26 PM|LINK
I like to keep things clean in my applications. Especially the URLs, however I have found that my routes table has grown to 62 routes, which includes all the paging, and altering of views. This seems like a lot to me. How many rules to do you have for your application?
next.to.tron
Member
38 Points
9 Posts
Re: How many rules do you have in your route table?
May 31, 2008 07:52 AM|LINK
18 :)
nberardi
Star
11233 Points
2352 Posts
Re: How many rules do you have in your route table?
Jun 02, 2008 12:13 AM|LINK
I wish there were better ways to classify and break down the rules. Because when you get past 10 you probably have to start gaming your order inorder to tweak performance.
ChanceUSC
Member
319 Points
209 Posts
Re: How many rules do you have in your route table?
Jun 02, 2008 06:16 AM|LINK
Do you mind if I ask what you are doing that requires 62 routes? That seems like a..lot..of routing going on.
dimi3
Member
318 Points
166 Posts
Re: How many rules do you have in your route table?
Jun 02, 2008 06:50 AM|LINK
That seems quite a lot. I tried and managed to have only a few routes (3). Perhaps I am doing something wrong or missunderstood something.
Why do you need so many routes?
It's interesting.
nberardi
Star
11233 Points
2352 Posts
Re: How many rules do you have in your route table?
Jun 02, 2008 03:50 PM|LINK
Well much of it involves layers and pairs of URL's. You can see the functioning site at http://www.ideapipe.com.
http://www.ideapipe.com/
http://www.ideapipe.com/upcoming
http://www.ideapipe.com/days/7
http://www.ideapipe.com/categories/politics
http://www.ideapipe.com/categories/politics/upcoming
http://www.ideapipe.com/categories/politics/days/7
http://www.ideapipe.com/groups/pipeline
http://www.ideapipe.com/groups/pipeline/upcoming
http://www.ideapipe.com/groups/pipeline/days/7
http://www.ideapipe.com/groups/pipeline/categories/ideas
http://www.ideapipe.com/groups/pipeline/categories/ideas/upcoming
http://www.ideapipe.com/groups/pipeline/categories/ideas/days/7
http://www.ideapipe.com/pages/2
http://www.ideapipe.com/upcoming/pages/2
http://www.ideapipe.com/days/7/pages/2
http://www.ideapipe.com/categories/politics/pages/2
http://www.ideapipe.com/categories/politics/upcoming/pages/2
http://www.ideapipe.com/categories/politics/days/7/pages/2
http://www.ideapipe.com/groups/pipeline/pages/2
http://www.ideapipe.com/groups/pipeline/upcoming/pages/2
http://www.ideapipe.com/groups/pipeline/days/7/pages/2
http://www.ideapipe.com/groups/pipeline/categories/ideas/pages/2
http://www.ideapipe.com/groups/pipeline/categories/ideas/upcoming/pages/2
http://www.ideapipe.com/groups/pipeline/categories/ideas/days/7/pages/2
Believe it or not all these URL's are processed through the same two Action Methods. However the Pairs are what kills me What I define by a pair are the following:
pages/{page_num}
days/{day_num}
upcoming
categories/{category_name}
groups/{group_name}
If the variable in each of these is not present then grouping from above should not be present. Or if the upcoming flag is on or off decides to display the popular ideas or the upcoming ideas that haven't become popular yet. Also all these pairs can be combined in any combination. The actual URL logic would look like this
http://www.ideapipe.com/[groups/{group_name}/][categorites/{category_name}/][upcoming/][days/{day_num}/][pages/{page_num}]
Everything in the square brackets are optional to the URL, but if the variable in the square bracket is present then the whole part of the square bracket should be present. I obviously could do this with just the variables but then I would have a ton of magic numbers in my URL. And this:
http://www.ideapipe.com/groups/pipeline/categories/ideas/days/7/pages/2
Would look like this:
http://www.ideapipe.com/pipeline/ideas/7/2
Then how would I differentiate between a group_name and a category_name. This problem accounts for 24 routes instead of a possible 1 actual route.
Also the 62 number is probably actually around 28 where 12 of them are the routes I just described, if I take out all the paging additions that I had to put in.
If anybody as a solution for me, that doesn't involve the magic numbers I would love to hear it. But this is the kind of Route table that a production application is going to have to deal with, if they don't want magic numbers in their URL.
IdeaPipe
TNE
Member
203 Points
57 Posts
Re: How many rules do you have in your route table?
Jun 03, 2008 04:01 AM|LINK
I have ~30 right now, its a pretty complicated setup but will be playing with it again and seeing if I can reduce it somewhat without increasing overal complexity of the readability. Its large though so that I can support www.domain.com/Username
Its hard to tell what you could do without seeing your actual routing code, but giving up your "pairs" and setting up defaults would help . "Pages/3" Is very unneccessary instead of just /1....99+. With the way the rest of the URL is currently formatted right now it wouldnt be very obvious what "7/2" is, I agree. So instead of days/1, days/7, days/30, days/356, and whatever else you may do - which isnt immediatly obvious what they are either without visiting your site and seeing the links I would change that "pair" to a more obvious Parameter "Today", "ThisWeek", "ThisMonth", "ThisYear" with a default when none supplied or some such would also help.
That should remove a few routes, but you're going to be left with quite a large table still because of the nested structure you want.
nberardi
Star
11233 Points
2352 Posts
Re: How many rules do you have in your route table?
Jun 03, 2008 12:49 PM|LINK
TNE,
Your point is well taken about the pairs. But like I said, if I got rid of the pairs the following URL:
http://www.ideapipe.com/groups/pipeline/categories/ideas/days/7/pages/2
Would look like this:
http://www.ideapipe.com/pipeline/ideas/7/2
Which would complicate things further, because groups and categories would get mixed up, because both are just strings that can occupy the same space. Same with days and pages. The days right now are static, but they could be dynamic in the future, with a slider dictating the range that is brought back. Also once you visit the site the URL starts to make sense in a contextual way. So I am not really concerned about the users who see my URL for the first time and don't understand it, because very few people are going to use that reasoning to not click on it and follow it.
IMO the nested structure is important, I just feel that working with routes could be easier. Since each of my URL's that aren't above start with pretty standard stuff like.
account
users
ideas
groups/{group_name}/management
I am probably going to make a custom handler that skips a whole set of rules, and fast forwards to the set of rules that start with say "account". So that the processor doesn't have to evaluate rules that I know aren't going to work.
TNE
Member
203 Points
57 Posts
Re: How many rules do you have in your route table?
Jun 03, 2008 04:32 PM|LINK
What you might consider instead is a catchall route and handle in code the splitting of pairs, that might work fairly well for you as your using the same action method for pretty much every request anyway.