We’ve all seen the most diverse kind of article of “Best web development ________”, “Applications to aid agile web development”… ahh that word “agile”…
The thing that worries me about all those buzz is that it’s all partial. I’m not crucifying people but its what to expect: If the writer is a Windows user, it’ll provide an article about Windows environment softwares and practices. (You can keep reading, this is not a Windows vs Linux post)
Jacob Gube (from SixRevisions) wrote
“In today’s development environment: faster is better.”
Yeah, for the client it’s awesome! But beware folks, ‘faster’ is dangerous. It can mean crappy code, made in a hurry just to follow the deadline or in the framework world, can mean excessive code running.
NOTE: I’m using various of Jacob’s statement just to illustrate the panorama. There’s nothing personal, mate!
The Myths
Use frameworks
Yeah, it’s neat. All those tools for you to make commom functions like milk with sugar. WOW!
I’m not an evangelist. I trully encourage the use of frameworks to small applications, those small ones that helps to pay the rent, but if you are going to build up a website or webapp that is going to have massive visitors or deal with massive calculations/features, I must encourage you to write your own.
I’ve worked with two particular php frameworks: Akelos and CakePHP.
They are awesome (my gold goes to Akelos) and have LOTS of functions for all you may imagine… but… think about your app, checking for all the feats you’re not using at runtime (request/response handlers, class existance, inflection, post/pre run filters…)?
Those frameworks are designed (thank god) to serve at many needs so it has to adapt to all situations. Are you hearing the sound of trouble?
Plus, they all have a ORM and DBAL that are definitely MUCH heavier than just doing the plain queries.
So, that’s my advice. If it’s small, framework-it, if its serious, write your own. I myself coded mine using parts of Akelos, you really don’t need to rewrite all. Just get the chunks, strip what you need and fit it into your code. Weight your case well and get the right tools.
In my road on development I’ve faced undersized projects that used DBAL/ORM and Frameworks and had to revert back to simple code to lose some weight. There’s also a known case of great service that we all know that had to leave the Rails Framework due overload.
The Zend Framework is nice beacuse you can use parts of them, instead of having the whole package. I haven’t got many experiences with it but it sounds nice. If anyone has any dark experiences with it please share!
Sidenote: About javascript frameworks, use-it at any stance. The load/run-time difference is not worthy re-writing. (but you still may have a project that will require custom js libs)
The php close tag
The latest myth (that I’ve read at Yongfook’s “10 Dirty Little Web Development Tricks”) is “Leave the php tag open (?>) because it makes no difference and prevent crazy space characters”. Ok… that’s dirty. (just this one, the others at the article are good indeed.)
Well, I say: MITH. It DOES make difference because the code was made to CLOSE the tag, not to leave it open. So why all you guys that proposed that go back to HTML instead XHTML1.1 STRICT? Go leave your tags open, use align=”" and stuff.
You know this is the kinda thought IE-only web developers think about “if it will render fine, there’s no problem on breaking the standards”.
Shame on you.
To prevent weird spaces write your code well and you’ll not have unwanted things. You cannot fall back to workarounds just because your code doesn’t respects you.
Use code that’s already written
That I advice heavily but you must to pay attention to see if the classes are still mantained! There’s lots of classes that has YEARS since last update (ok, some doesn’t need updates but makes me think twice before using it). The great thing about using third-party classes has the same principle of OSS (because it IS OSS indeed): There’s people oftenly working on that “arm” of your app.
I support Jacob where he alerted:
Beware though: this only really works when you know what you’re doing and have enough experience to tell the difference between good and bad code. Otherwise you might find yourself with a buggy or poorly-written end-product.
Beside, beware with every code that was not written by you!
Conclusion
THERE IS NO ABSOLUTE TRUTH!
Probably the main reason that articles leave that gaps is because they all try to serve a cake recipe that fits all needs. This is plain utopia. Software development can’t be THAT conventioned. Every case needs specific technology studies and so the resources carefully studied BEFORE implementation.
Many people (I’ve done that earlier times) look for the answres to be posted on someone’s blog but, guess what, there isn’t!
Plan your project, get the available options to be used and then study them, weight the PROS and CONS of each one and then make your choice.
As my friend says “The project WILL CHANGE and so your plannings unless you work backwards.”
Jan,
I see your concerns. It’s true – it’s very hard to fit developers into one mold. But when you quote me on “faster is better”, I think you are sort of implying that I’m advocating speed at all cost, regardless of quality – which can be farther from the truth. I don’t think that producing faster automatically equates to poorer-quality code – the article aims to speed up your workflow and your processes, not make you take ill-advised shortcuts.
For example, with IDE’s: they improve your work processes and bring together all the tools you need in a convenient interface, saving you from learning multiple applications and cluttering your workspace with multiple apps.
For your framework comment: I’m not thinking large-scale, highly-customized apps (though Twitter did manage to do it with Rails) – I was thinking generic applications. At the same time, it’s got to be a very complex system for its requirements not to be met with a solid framework like Rails or Zend. I’d have to disagree that using frameworks to speed up development time is myth: more often than not, it speeds up your production – but we also have to take into account that it’s a tool to get things done, it’s up to the creator to wield that tool properly.
About using pre-made classes: again, I emphasize that you should know what you’re doing. For example, I was looking for a Yahoo! Search Boss class for a site-specific search (to try and save me some time or at the very least, to get me started) – alas, I did not find one that’s well-written, so I wrote my own. And that’s just it: If you don’t know how a piece of code works, you shouldn’t be including it into your projects.
Finally, the article is meant as suggestions, “ways you CAN save time”, not “things you NEED to do to be an effective developer”.
Thanks for reading my article, and thank you for sharing your viewpoint.
Jacob Gube
December 17, 2008 at 4:24 pm
Jacob,
I’ve tried to make this article the less “Implying” possible, even left he message for you to not take it personally.
The thing in focus I criticize is that most of the articles defends their opinions without giving the reader the CONS and without giving the scenario (generic apps) that we are talking about.
The result as i’ve seen many times are people taking this as the only truth.
In fact, “frameworks to speed up” itself isn’t a myth but if you generalize, it is (not saying you did).
Not attacking, just giving the full side of the story =)
Jan Seidl
December 17, 2008 at 4:44 pm
Re: leaving out the close tag in PHP-only files. It is good advice. When you’re talking about hundreds of classes in your application and you see your app dying with ‘Headers already sent’ error, you’ll understand why. Comparison with malformed HTML is ridiculous and completely off.
anon
December 29, 2008 at 8:49 pm
what this guy said.
plus it’s one of Zend’s coding standards (you know, the guys who created php…) to leave off the closing tag in php-only files. I like to think they know what they are talking about:
http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html
it completely eradicates the possibility of header-related errors caused by whitespace in php files, therefore it can only be a good thing.
the fact that a close tag exists doesn’t mean you’re meant to close it, it just means you’re meant to close it if something non-php appears after your php code. your comparison to html doesn’t make sense at all, that’s a markup language with entirely different rules. apples & oranges.
yongfook
December 30, 2008 at 2:38 pm
Well, Its not because the guy invented the language that he can rule the coding standards.
Its not needed, ok. But it exists so it shall be used. I disagree with the Zend guy, even he creating php. This statement of his just make me wonder if I want to use a language where the author tells you to code poorly.
Its not apples and oranges. Yes, we are talking about markup vs processing language but structure is structure.
If your FTP or IDE or ANYTHING puts unwanted data on your code, switch your application.
Accidental whitespaces. Accident happens when errors happens. A stable code/environment shall not have “accidents”
Jan Seidl
January 7, 2009 at 3:50 pm
Gotta agree with Jan on this.
If PHP code is to be delimited by , for me, the very definition of “delimited” says that I shall have in the end, at least, according to the PEAR Coding Standards.
Granted, it works without it, but I don’t think it’s good practice to leave it out.
Accidents? If there’s a whitespace in the end of my files, it’s because I put it there, and I know what I’m doing. There are no accidents (at least not like this).
Bruno Lustosa
January 7, 2009 at 4:03 pm