2 ms·
I couldn't agree with this rant more. I use frameworks because they streamline my code, and provide basic abstractions for simple tasks. One of my biggest iss
by michaelchisari 16y ago
I couldn't agree with this rant more. I use frameworks because they streamline my code, and provide basic abstractions for simple tasks. One of my biggest issues with Rails (to be fair, it's more about people new to rails), is the way it sees abstraction as a form of magic. Simple tasks should be abstracted, but abstracting complex tasks is a recipe for disaster down the line, when you need to operate outside of the confines of the abstraction. This can be mind-numbinglyannoying for experienced programmers, and frustrating for new programmers.
I do want to address specifically the idea of abstracting out things like HTML or SQL. These are my two pet peeves. I look at something like HAML, and I can't understand why anyone would consider that to be a good idea, even putting aside the fact that your designer will have to learn a whole new syntax, but the idea that markup should look like programming language defeats the point of a markup language.
Here's how I did it with Appleseed, using the simple_html_dom library. Views are dumb, very dumb. You create a view which is only markup, for instance:
http://github.com/appleseedproj/appleseed/blob/master/components/friends/views/friends.php http://github.com/appleseedproj/appleseed/blob/master/compon...
So you properly class and id your markup, and in the controller, you populate the data, repeating elements for lists or tables, by targetting the dom.
If I want to set the title on this view, I do:
$View = $this->GetView ( 'friends');
$View->Find ( '.profile-friends-title', 0 )->innertext = "New Title";
That's it. No template pseudo-code, designers only have to care about the markup itself. On the front-end, I do the same with Javascript. Think of it as unobtrusive PHP.
I also stay away from ORM's. I understand all the arguments in favor, but in the end, I'd much prefer writing complex joins than using an ORM.
Separation of concerns is so important, and yet, sometimes I think frameworks, which are supposed to facilitate that, actually can make it worse, by trying to reinvent the wheel in abstract ways.