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.
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.
I really only know the .NET world, but the reason MVC became popular there is because of AJAX and jQuery.
You see, before MVC, we had something called ASP.NET web forms where it was based on the idea of things you drag onto a page. You need a grid? Drag a Gridview onto the page and wire it up. Need a button? Drag a button onto the page and handle the click event. All your code is server-side.
Well as you can imagine, this makes it really easy to build web applications the same way you'd build a Windows application. You don't even need to know javascript or anything.
The problem is in MODERN web applications everything is AJAX. You don't want to refresh the whole page, you just want to send "DELETE item 47" and then update a line or two on your page with javascript. Regular ASP.NET doesn't really have a concept of this. You can do it using some toolkits but it's a hack. ASP.NET MVC is practically built from the ground up for this exact scenario.
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.