Is URL construction Business or Design Logic?
Posted: Sun May 01, 2005 1:27 pm
In a normal context URLs are very simple things.
Nothing much to see here. But then, you have the ability to put GET parameters on files, like:
I'm sure all of us, at one point, constructed these URLs in a fashion like this:
Of course, this presents problems if you have a page where:
- You have multiple filters that are passed through GET
- You want to have this extend over multiple pages
How do you know which GET variables to stick into the URL and which ones not to? It looks like you might want a formalized URL parsing structure.
Plus, the structure of a URL poses some interesting difficulties.
What if paramater one is not set? Do we:
...where you simply run through all the parameters
...where you simply check whether or not a paramater is used, and if not, omit the param1=value1 but not the ampersand
...where you always have a question mark, and then you just add "param3=value3&" blocks to the end.
Ideally, it would be like this:
But then you need to know all the paramters being passed before generating the URL.
And you want to be able to do that last thing, but as mentioned before, you need to know all the paramters. Gone are the days now of ad hoc, you need a formalized infrastructure for URL generation (or at least dynamic URL generation)
But, if you use a templating system, does this mean:
where we have retreated URLs to the PHP side?
Does URL construction constitute design logic, and thus must be done in the templating system and If it is business logic (aka not-design), doesn't this mean a significant viewability hit where it is difficult to custom-make URLs in new pages and it is difficult to figure out exactly where a URL points?
Code: Select all
img/picture.jpg
index.htmlCode: Select all
index.php?mode=edit
search.php?searchid=81278372&list=ascCode: Select all
<a href="e;index.php?mode=<?php
echo $mode;
if (!empty($order)) {
echo '&amp;='.$order;
}
?>"e;>This is the link</a>- You have multiple filters that are passed through GET
- You want to have this extend over multiple pages
How do you know which GET variables to stick into the URL and which ones not to? It looks like you might want a formalized URL parsing structure.
Plus, the structure of a URL poses some interesting difficulties.
Code: Select all
index.php?param1=value1&param2=value2&param3=value3Code: Select all
index.php?param1=&param2=value2&param3=value3Code: Select all
index.php?&param2=value2&param3=value3Code: Select all
index.php?param2=value2&param3=value3&Ideally, it would be like this:
Code: Select all
index.php?param2=value2&param3=value3And you want to be able to do that last thing, but as mentioned before, you need to know all the paramters. Gone are the days now of ad hoc, you need a formalized infrastructure for URL generation (or at least dynamic URL generation)
But, if you use a templating system, does this mean:
Code: Select all
<a href="e;{$url.nextpage}"e;>Next Page</a>Does URL construction constitute design logic, and thus must be done in the templating system and If it is business logic (aka not-design), doesn't this mean a significant viewability hit where it is difficult to custom-make URLs in new pages and it is difficult to figure out exactly where a URL points?