3 ms·
I rarely go off like this but man, look at this PHP file! It's a mess! Very long, not dry, no wonder the dev fat fingered it... Is the rest of the framework l
by jjm 16y ago
I rarely go off like this but man, look at this PHP file!
It's a mess! Very long, not dry, no wonder the dev fat fingered it...
Is the rest of the framework like this?
No headless output testing? Manual output checking (at the least)?
For the record, as much as I hate to admit it now I was a big long time PHP developer. My code is used round the web today...
- datasink 16y agoIt's a config file. How can you make dozens upon dozens of unique memcache, database, and defined constants DRY?
- mickeyben 16y agoI pretty much agree with jjm comment. I never have ONE config file but a directory of config files, everything is separated : database, memcache, heywatch, s3, routes, ... It's way easier for the developer, the sysadmin, the deployment, ... Of course it would multiply the risk of this happening by n files.
- jjm 16y agoThats the point. Who says it has to be a config file? Think outside the box. Here is how Flask can do configuration (a Python micro framework): <code> class Config(object): DEBUG = False TESTING = False DATABASE_URI = 'sqlite://:memory:' class ProductionConfig(Config): DATABASE_URI = 'mysql://user@localhost/foo' class DevelopmentConfig(Config): DEBUG = True class TestinConfig(Config): TESTING = True </code>
- datasink 16y agoZend Framework also handles configs with inheritance. It's an elegant way to handle overrides, no doubt. They do one better by allowing the definition to be in ini files, which would have circumvented the Tumblr bug. Still, I think config files are often best when they're verbose and as straightforward as possible. There are fewer surprises this way. If I'm working on a project by myself or with a very small team of people I trust, I'd go the inheritance route. If the team is larger, I'd go the verbose route.