[wp-hackers] The problem with WP_Rewrite <<< RE: Options for Controller - Views
Mike Schinkel
mikeschinkel at newclarity.net
Thu Dec 3 22:18:04 UTC 2009
On Dec 3, 2009, at 4:39 PM, Otto wrote:
> On Thu, Dec 3, 2009 at 1:18 PM, Christopher O'Connell
> <jwriteclub at gmail.com> wrote:
>> Your argument just doesn't make sense. By your logic, we shoudn't abstract
>> away SQL, because "if a person is not capable of understanding SQL, and
>> can't look in a book for 10 minutes to figure out what they want to do, then
>> they should not be writing code of any kind. They should stick to something
>> simple, like flipping burgers."
>
> Actually, SQL was and is designed to be used by end-users directly for
> gathering data and reporting and such. In other words, in a properly
> designed system, yes, the end-user (business user) does have direct
> access to the database and can run arbitrary SQL commands. The
> database might not give him permission to UPDATE or DELETE or what
> have you, but a database is explicitly designed to be a multi-user
> environment like that.
>
> Let me rephrase that: SQL is designed to be used by *business people*.
> Not programmers.
There you go again with your opinions as if they were "decried from on high."
In my experience, most "business people" will do whatever they can not to have to learn SQL. A graphical query tool, yes, but not a text-based query language.
Yes, it's my opinion but as such it is as equally valid as yours.
> The only real reason we abstract it out is because we have only a
> small subset of SQL queries that are needed for the application at
> hand.
Only reason? (You can't prove a negative.)
Well, having a small subset is the same that can be said for URL Rewriting.
>> The reason we abstract stuff away is to simplify programming. It's a common
>> use case to redirect a URL to a controller (and that's what it is, no matter
>> what you want to call it). It should therefore be simple. I don't know how
>> they do things in the South, but out west a couple of dozen lines of code
>> including RegEx is NOT SIMPLE! Indeed, it's so not simple, that it's broken.
>
> I don't know exactly what you mean by "controller", but let's assume
> you're talking about the bit that chooses your "view" (template from
> the theme in this case).
>
> The example I gave before was about 8-10 lines of consequence. That
> was to redirect "/products/whatever" to a whatever.php template. If
> you wanted to also add, say, /reviews/whatever to that code, it would
> take 3-4 extra lines (depending on your coding style).
>
> You're looking at this from the point of view of "redirecting a URL to
> a template". But I'm looking at this from the point of view of what
> you *actually* want to do, which is to parse the URL and then
> determine and load the right template. These are actually equivalent,
> but for some reason, you are not seeing that fact.
>
> Let's say I wrote you a new function, called redirect_URL_to_template.
> It'd work like this:
> redirect_URL_to_template('products');
>
> What would it do? Well, it would redirect /products/whatever to
> products/whatever.php in your theme, for any given value of whatever.
> You could call it over and over and add as much as you wanted.
>
> Then you come to me and say "Why can't I redirect /reviews/something
> to /notreviews/something.php?" And I tell you, well, because the
> function doesn't work that way. And you tell me "Well make it work
> that way". So now the wrapper function becomes more complex. And then
> somebody else wants it slightly different.
>
> Pretty soon you have either dozens of wrapper functions, each very
> similar but doing different things, or your wrapper function is so
> complex that nobody can figure out how to use it.
If there were not a small set of patterns for URL rewriting, your argument would make sense. As is, it does not.
Besides, your small argument could be applied fallaciously to practically anything of complexity, i.e. the admin menu functions. It doesn't apply there any more than it applies here.
> Or, I could teach you "this is how the system works, it's pretty
> simple but you do have to think a small amount, however it's powerful
> enough to let you make any arbitrary URL do any damn thing you like,
> whether it be routing to views, or calling functions, or even
> downloading the complete works of shakespeare.. You can do anything
> with it, and all you have to learn is this extremely tiny subset of
> regular expressions. And by extremely tiny, I only mean what these
> characters do: .*?+[]()$ Seriously, that's probably all you ever
> need.
>
> What makes more sense?
Simplification that removes the black art of regular expressions from the URL rewriting interface that most people will use makes the most sense.
>> P.S. Brewing beer, is, IMHO much simpler than RegEx
>
> As a homebrewer and programmer, I find that highly offensive.
> Brewing is a far, far more complicated process. If you're doing it right, I
> mean. Any old idiot can throw a prehopped malt in and do a boil, I
> grant you, but if you really care about your beer, it takes more
> effort than that.
Offensive?
As you've told me, don't take things so personally. ;-)
>> P.P.S. This reminds me of the discussions on some of the linux boards about
>> how "including a graphical package manager is totally unneccessary, because
>> there's a command line one".
>
> Funnily enough, on my Fedora install, I'm always popping up a command
> line to run yum, because PackageKit sucks and is hard to use.
And some people are only able to see things from their own perspective. So there you go.
Oops, I thought I was done with this. There I go again.
-Mike
More information about the wp-hackers
mailing list