Frameworks And 'traditional' coding
Sorry if this too open ended for this forum, but here goes.
I mostly use languages such as PHP and Javascript without frameworks (e.g jQuery, Drupal, CakePHP). The only real 开发者_JAVA百科exception to this for me, is Wordpress when 'traditional' coding is slower for building information sites.
I've dabbled with several frameworks over the past year and despite everyone else's (seemingly) good experiences with them, I seem to of hit a roadblock. My basic problem is that for the amount of time invested in effectively relearning a language, I don't get a lot in return. jQuery as an example: there is really very little in that, that I couldn't accomplish easily with a few getElement..
commands. So my question is, what advantages do frameworks offer over previous coding styles?
Thanks from 2003 guy!
To be simple: if your audience absolutely requires IE, use a library. If not, avoid it. The DOM API is sufficiently consistent and powerful in all other browsers. More about this issue here: http://azabani.com/51
See:
Why Use a PHP Framework? The Benefits Explained
For me frameworks are life-savers, it is just initially that you invest your time in learning them. Once you have mastered them, you feel pretty much at home.
Traditional programming is time-consuming and highly error-prone and most importantly only you are responsible for debugging the issues and more because you have written it all in your own style.
If you feel that learning jQuery is "relearning a language", then you probably need to work with Javascript some more, and do some reading about the nature of the language. Each of the popular frameworks impose a certain style of Javascript, each with its own foundational conceit upon which various facilities are built. However, they're all just Javascript, and the techniques they use aren't magic or special.
What you get from a framework is that stylistic consistency, coupled with the investment of time that the framework designers have spent towards ensuring cross-platform compatibility and performance. Yes, because it's all just Javascript and DOM APIs, you could certainly do it all yourself. It is a great thing, even as a full-time jQuery fanatic, to be fully aware of what those DOM APIs are and what they do, and to be fluent in their use. For the practical construction of real, production web sites, however, why would you want to shoulder the entire burden yourself?
I guess if you already have a very big library with self written code, you can go with that. However every Framework does much work from you, and prevents you from making some simple mistakes or writing boiler plate code over and over again. Additionally a Framework can introduce you to new Design Patterns, that you have not used before but are now forced to use.
However you should always adapt your tools to your projects:
Simple Project: Own Library, forget about "bloaty" Frameworks Complex Project: Use a Framework that does much of the work for you
In my opinion frameworks make life more easier, regarding to maintaining a larger web project. Most features are preprogrammed and ready to use. Often those frameworks offer different functions like multi-author and so on, which would need relatively much time to program it by hand. In my eyes such frameworks make sense when you have many edits in your content.
For a private Homepage, which is edited twice a year, such a framework won't make that much sense. Maybe it's nice to have a WYSIWYG-editor inside and donÄt have to upload something.
In my eyes frameworks are good for people, that aren't able to programm pages by hand or are so good, that people just don't want to hang up with "stupid coding" but editing the content.
For people like me, who want to have a learing effect, such frameworks don't offer much things to learn, because everything is done in browser. In this case only coding some extentions (joomla for instance) or something like that can bring me further.
At least it depends on the project (how big, how often to edit,...) and the one who realizes it ;-)
精彩评论