[wp-hackers] The problem with WP_Rewrite <<< RE: Options for Controller - Views
otto at ottodestruct.com
Thu Dec 3 21:39:53 UTC 2009
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*.
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
> 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:
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.
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
What makes more 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.
> 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.
More information about the wp-hackers