IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New His solution is more general than that
The basic solution can be read as, Decide the API that you want to program to, create a compatibility layer that supports that API for each platform, program to that compatibility layer. In the simple case the compatibility layer is trivially simple in one case.

If you'll read [link|http://www.oreilly.com/catalog/opensources/book/linus.html|http://www.oreilly.c...s/book/linus.html] you'll note that the solution within Linux for how to support so many architectures takes this exact form, again.

In this case you can follow a strategy like this (written in Perl, badly):
\n# A badly done compatibility layer.\nmy $DATABASE;\nif ($IS_DEVELOPMENT) {\n  ...\n  $DATABASE = 'DEV';\n  ...\n}\nelse {\n  ...\n  $DATABASE = 'PROD';\n}\n\n# and outside of the compatbility layer...\nmy $dbh;\nsub open_connection {\n  unless ($dbh) {\n    # If somebody typoed, there will be no database\n    # to connect to of the name this gets, and things\n    # will (properly) blow up.\n    $dbh = open_database($DATABASE);\n  }\n  return $dbh;\n}\n

Now the error that you had becomes very different. Getting the variable name wrong somewhere results in an instant highly visible crash.

The flaws in how I've written this are many.

For one thing you often want to support cascading defaults since many configuration variables should be the same in development and production. But cascading defaults open you up again to accidentally having something cascade that shouldn't. Therefore have both development and production cascade back to sane defaults. Most configuration items go into the defaults. The few that have to differ do not go into the defaults.

For another you're likely to need at least 3 environments some day. (Development, staging, production.) Build that flexibility in. I've seen multiple ways of doing that. One of the better ones is to build up a hash of hashes. Each sub-hash is a possible configuration. The outer hash is a mapping of environment to configuration variables. In building it up, you make some sub-hashes start as copies of others - right there you have your cascading logic! That is very nice if you, for instance, want to give each developer their own machine with a customized installation to play with.

But for all of its flaws, the above demonstrates the key idea. Have a section devoted to configuration information only. Then don't scatter if-tests around. Instead have other functions that act in a very generic way upon the configuration data.

Cheers,
Ben
To deny the indirect purchaser, who in this case is the ultimate purchaser, the right to seek relief from unlawful conduct, would essentially remove the word consumer from the Consumer Protection Act
- [link|http://www.techworld.com/opsys/news/index.cfm?NewsID=1246&Page=1&pagePos=20|Nebraska Supreme Court]
New Finally had time to reply to this
And the reply is, "Yeah, no shit."
Then don't scatter if-tests around.
The reason it was written this way is that the devel database is not actually a complete snapshot of live. Lots of tables and some whole databases aren't there, so pages break horribly in the devel environment. This should of course be solved by replicating the rest of the db. Instead it was handled by adding a configuration option to the db class to over-ride devel mode and connect to the live server anyway. So the developer then had to track, "For this function I want a connection to the live db, for that function I want a connection to devel."

That stops now. Devel is devel, and if it doesn't work in devel then you fucking fix it.

For another you're likely to need at least 3 environments some day. (Development, staging, production.) ... That is very nice if you, for instance, want to give each developer their own machine with a customized installation to play with.
Actually we've got four:
  • Devel, where each developer has his own vhost and all db connections (starting tomorrow morning) are to the devel db.
  • Stage, for testing (assuming we hire some testers [sub-rant deleted here]), which also (as of tomrrow morning) points to devel db.
  • Cert, for QA (assuming we hire ... oh, I already went there) which points to live data.
  • Live.
===

Implicitly condoning stupidity since 2001.
New Re: Finally had time to reply to this
The thing is, devel needs full-time attention like live, and it never gets that, because it's junk (not really, but...)
-drl
New That's backwards :-(
The reason it was written this way is that the devel database is not actually a complete snapshot of live. Lots of tables and some whole databases aren't there, so pages break horribly in the devel environment. This should of course be solved by replicating the rest of the db...

It sounds like changes have been made directly on live and never propagated back. Which means that you're walking on a highwire twice.

Of course the way that you should do it is write scripts to update dev, and then when you're happy, run them against prod. That way dev either matches prod or is ahead of it. (Data, of course, gets copied from time to time from prod to dev.)

But you know that. Convincing the rest of the company is your problem...

Cheers,
Ben
To deny the indirect purchaser, who in this case is the ultimate purchaser, the right to seek relief from unlawful conduct, would essentially remove the word consumer from the Consumer Protection Act
- [link|http://www.techworld.com/opsys/news/index.cfm?NewsID=1246&Page=1&pagePos=20|Nebraska Supreme Court]
New Gosh, really?
Remember, we didn't have a devel DB until recently. Building a new one from scratch takes one of our report servers out of the rotation for most of a day, so we've been copying stuff "as needed".

Our other problem is that the one person who has access to make changes on the live DBs doesn't use the devel DBs at all.
===

Implicitly condoning stupidity since 2001.
New Gah. I wish that was unusual. :-(
To deny the indirect purchaser, who in this case is the ultimate purchaser, the right to seek relief from unlawful conduct, would essentially remove the word consumer from the Consumer Protection Act
- [link|http://www.techworld.com/opsys/news/index.cfm?NewsID=1246&Page=1&pagePos=20|Nebraska Supreme Court]
     [ siiiiiiiiiiiiiiiiiiiiiiigggggghhhhhhhhhhhhhh ] - (drewk) - (17)
         Does PHP have the equivalent of 'use strict;'? - (ben_tilly) - (8)
             or Option Explicit for the VB world :-) - (ChrisR)
             Trying to figure out how I can use this - (drewk) - (6)
                 His solution is more general than that - (ben_tilly) - (5)
                     Finally had time to reply to this - (drewk) - (4)
                         Re: Finally had time to reply to this - (deSitter)
                         That's backwards :-( - (ben_tilly) - (2)
                             Gosh, really? - (drewk) - (1)
                                 Gah. I wish that was unusual. :-( -NT - (ben_tilly)
         Using PHP since 2001, I see... :( -NT - (FuManChu)
         Yup, many compilers just leave . . - (Andrew Grygus)
         This is why I dislike PHP's set-ness model. - (static) - (4)
             Re: This is why I dislike PHP's set-ness model. - (deSitter) - (3)
                 PHP and "set" variables. - (static) - (1)
                     gawd - (deSitter)
                 (Dupe.) -NT - (static)
         Just off a 42-minute call, 3 a.m. local time, must sleep - (drewk)

Hard science if ever there was.
74 ms