Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Using homogeneous architecture has tremendous advantages over using a patchwork of different formats and languages.

Quick example. If you're using native PHP templates and configs, installing APC gives you instant template and config caching with zero effort. To get the same functionality for other formats you would need to roll our your own caching, introducing bugs and complexity along the way, but, most importantly, reinventing the wheel.

That's just one out of myriad examples.

Also, if you have more than two nested levels of arrays (regardless of the language used) in a giant uber-config file, you are the one who is shooting your users into their feet.

Don't code XML in PHP. Refactor. Use includes (which JSON doesn't have, BTW). Use autoconfig pattern and align your configuration file with classes that use them. Use sensible conventions over configuration. Start the file with return statement instead of magic name:

  <?php
   return array(
     'var' => "val",
   );
Nothing will ever scale if you don't even try to design it in a sensible way.


I didn't know that you could return a value from an include like that, that's incredibly handy (and makes me wonder why almost nobody does it that way).


I love this strategy, it's great for config. For example in the RocketSled microframework I mentioned earlier[1] you have a config file to instruct the system which class to execute by default in which you just put:

<?php return 'Hello World';

Being able to include a file like that in your project which returns a value has the advantage (in my opinion anyway) of not cluttering up the namespace with lots of defines(), of not requiring any magic naming convention, and of not having to call out to any external functions or edit config files that are part of the core system's version control.

[1]https://github.com/iaindooley/RocketSled




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: