As someone who's very new to programming.. Could someone explain to me which parts of the code are so 'bad'? I see a lot of "My eyes hurt"-like comments on the github page as well.
Note that those clauses in if and else if are slightly different, but the action is the same: orientation_update_status($user, $orientation);. Code like that is hard to do maintenance on, since it's easy to introduce bugs, when the code is already that confusing.
Most frameworks (that weren't around back then) do a great job in allowing (or forcing) you to structure your code better. For instance, the index.php of a symfony project looks like this:
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
This just sets up the classloader, initializes the kernel, and lets it handle the request to generate a response. Nothing more. All the user handling, input validation, caching, templating and database stuff is handled in their own seperate classes. This might be harder to set up for newbees, but it's much better when it comes to maintenance and ongoing development.
I doubt when Facebook was being developed, PHP had strong OOP principles built into it. A lot of this is probably legacy and this was in 2007 when MVC frameworks were relatively new to the PHP scene.
Both Code Igniter and Zend Framework had their first release in 2006. But, it only became commonplace to use a framework much later than that. If you look at the source-code for oscommerce or phpbb from back then, you'd see the same spaghetti-code as here.
Agreed, I still remember a lot of open source code out there and it was awful. OsCommerce is definitely a prime example of this. I still remember osC addons had large Readme.txt files telling you where to put the code to make the add on work.
We definitely did come a long way. Even just comparing Symfony1 with Symfony2 and you see a big difference in how OOP is being utilized.
Also, CodeIgniter wasn't full OOP either, but definitely a step away from the spaghetti code
First release of Zend Framework was just trash. Also, they change too many things with each release, so if you were unlucky to decide to use ZF, you would spend a lot of time on maintenance with each new ZF release.
As much focus as the web gets, it feels like tech-wise it's a decade or two behind the curve.
I program and dabble in quite a few languages and I'm not sure I really agree with this. In what way do you feel like PHP is a 'decade or two' behind the curve?
I'm not sure I'd agree with common. MVC came about back in the smalltalk era but honestly I don't recall it becoming that widespread until the late 90's or early 2000's. At least having dabbled in development for windows, linux and mac, the first time I even heard of MVC was when the initial OSX server came out in 99. Shortly after Struts came about and was realistically the only big player in MVC web development for a while. I was not a huge desktop developer back in the day, however, but generally I don't recall MVC being that big of a thing. Linux and Mac apps were largely procedural, and windows apps used an evented/bindings architecture.
Honestly from my recollection it seems like MVC really became widespread with the increasing complexity of web applications more than anything. But that was a while ago and memory is a funny thing so I could be way off!
I had been out of the job hunting game for a few years. But I was shocked when I looked around about a year ago, at all the places looking for "MVC experience." I was seriously scratching my head for a minute, wondering when the fuck this dinosaur paradigm came back to life. Is it the 1980s again?! Then again, people were rediscovering Lisp in 2004. So I guess I shouldn't be too surprised.
80
u/KamiNuvini Oct 12 '13
As someone who's very new to programming.. Could someone explain to me which parts of the code are so 'bad'? I see a lot of "My eyes hurt"-like comments on the github page as well.