Comments:""Don't Reinvent the Wheel! Use a Framework!" They All Say. | mogosselin.com"
URL:http://www.mogosselin.com/dont-reinvent-wheel-use-a-framework/
I see it more and more. In tutorials, on Youtube, blog posts, StackOverflow answers. If you want to fix something or develop a particular feature, you’ll probably stumble on “download that framework, take this library, install this, click there” type of tutorial.
But where’s vanilla JavaScript? In exile somewhere? Buried in JQuery’s basement? And since when is WordPress a framework to develop Web applications?
Oh, and by the way, if I want to develop a simple Web application with a single form in Java, I probably don’t want to install Spring, Spring MVC and Hibernate.
OK?!
</rant>
Is WordPress a Framework?
First, it doesn’t seem really clear what the differences between frameworks, libraries and Web development platforms are. Here’s a little list to help you understand if you’re just starting:
- Library: Code written to create shortcuts over another language. Examples: JQuery for JavaScript, Apache commons for Java.
- Web frameworks: Starting “tools” helping you with common problems. For instance, in Web development, we often need to map URLs to code somewhere. A framework will make this easier (hopefully). Example of Web frameworks: Laravel and Code Igniter for PHP. Spring MVC and Struts for JAVA.
- Web development platforms (and similar): A more general category. In this one I include every application with a content management system (CMS), out of the box features for users like a forum, blog, or anything higher level. Example of Web development platforms: WordPress or Joomla for PHP. Liferay or Magnolia for Java. Orchard for C#.
Why “You Shouldn’t Reinvent the Wheel” Doesn’t Apply to Frameworks
So, what’s the problem with using a framework/library/platform you ask? You shouldn’t reinvent the wheel, right?
You know what, that’s a bad analogy. It just doesn’t work, it’s too simple to define the use of frameworks or CMS/CRM or libraries this way. Web developers are not using wheels, they are making cars.
If you are building cars, yes, you can reuse wheels IF you understand how they work in different situations and with different kinds of cars. Otherwise, if your car doesn’t work the way you want, how can you fix it? Kick the tires?
Sure, for the people working in Web development since 10 years, we can manage. Depending on our needs, we’ll know how to find vanilla JavaScript code without JQuery if we don’t need that big library. And if we don’t find anything? We’ll write the code ourselves
The problem is to always tell beginners (or let them think this is a good idea) to start with a framework / cms because “you shouldn’t reinvent the wheel”.
Should Beginners Use a Framework for Web Development?
Here’s when beginners shouldn’t use code written by somebody else:
- When they want to learn a programming language
- When they’re paid to do a job and don’t understand how the framework/library really works
When they should use a framework:
Problems that Arise When Using Frameworks
It’s nice not “reinventing the wheel”, but it’s not always 100% happiness.
Here are some problems we all come across while using frameworks, libraries and Web development platforms:
1. Customization can be difficult in complex code.
Take for instance Liferay. Liferay is a big web development platform. If you want to start a membership site and don’t care about how the “out of the box features” are working, it’s nice. If you can compromise on the look and feel, no problems. Liferay has everything: a forum, blog, user management, content management system. The list is endless. But, if you want to customize it a little bit, it can be cumbersome.
According to Ohloh Liferay has 4.1 million lines of code. If you want to change something, it’s somewhere in there.
Often, while using Liferay, I had to go look into the sources to understand what it was doing. If you don’t know the basics of Java, you won’t be able to do much.
The more complex the framework, the harder it is to customize it.
2. Debugging is usually more difficult when using frameworks.
Frameworks are good at throwing unreadable meaningless errors. I’m not saying that it always happens, but when it does it’s annoying to debug. If you’re a beginner and you don’t even understand the language, how can you fix those problems?
What’s Good About Frameworks?
Good things happen while using frameworks too:
1. Good frameworks will enforce good development practices.
If you’re starting out, choosing a framework to experiment with can be a good idea. You’ll be able to learn about design patterns such as MVC. I would advise to use lightweight frameworks and staying away from libraries and development platforms if you’re just starting.
2. A good example (most of the time)
Good open source frameworks will show you how code should be written. If you can choose a framework, chose one that is open source and browse its code. You should be able to pick some tricks here and there.
3. Less bugs and tested code
It’s especially true with libraries. The code you’re going to use, if picked carefully, will already be tested and will contain less bugs than what somebody would code from scratch.
4. Reusing code
Isn’t it nice not reinventing the wheel?
So, what’s your opinion on using frameworks, libraries and Web development platforms?
Wheel picture by ginnerobot