Using a Framework Or Not
Using a Framework Or Not
The debate between frameworks or code-only continues, and MVB Nicolas Frankel looks at the factors that might impact such a decision.
Join the DZone community and get the full member experience.Join For Free
Discover how you can take agile development to the next level with low-code.
If you haven’t read Uncle Bob's latest blog post, you should do so now. For impatient readers, it can be summed up with:
tl;dr: You don’t need frameworks, just write the appropriate code.
tl;dr: Better understand the underlying layer than become a framework specialist.
As for software, why would anyone in their sane mind still use a framework? Because frameworks are about being productive, i.e. saving precious time! Something like Joda Time might not be the next best thing since sliced bread, but it’s nicely designed and it's readily available. Could I cook something like this? Probably, given enough time. But here lies the rub: in a project, you don’t get time to create your own low-level libraries. There’s a budget and you'd better not overspend. Anyway, should I have time left, I would prefer to increase my test coverage, run some some mutation testing or refactor that part I’m not very proud of.
Refusing to reuse even has a name in software engineering, the NIH syndrome. There have been several examples of developers developing their own custom framework instead of an existing one, because they thought they understood the problem better than others. It usually ends up in an tangles mess of half-baked code, with zero documentation and a huge learning cost. Interestingly enough, examples I personally witnessed first-hand are about data persistence. Folks, don’t do this at home! Or better, do it at home for learning purpose, don’t do it at work…
There are a couple of hints that let you spot NIH:
- A company policy prevents you (or hinders you so much it prevents you) from using a third-party library for “security” reasons — though Open Source code is much safer than closed source, thanks to the power of reviewing. You’re welcome to read this piece of art from Oracle stating the opposite, which has been removed since.
- A person enforces the use of the code he developed, even though it’s not documented and not tested. A solid Open Source framework does the same, and his position of power prevents them from doing otherwise
Of course, when you need to use a framework, that doesn’t mean you should use the first one you stumble upon. I firmly believe that knowing of a couple of reliable frameworks in different domains (logging, reactive, UI, metrics, etc.) should be part of a well-rounded software engineer portfolio.
One has to look at a few things before making the choice of using a framework, but they can be summed up in one question: “Will it be maintained?” This criteria can be evaluated through a couple of factors:
- Number of committers
- Frequency of commits
- Date of last commit
- Nature of the licence
- Size and activity of the community
All the frameworks I use (SLF4J for logging, Vaadin for UI, Spring for Dependency Injection, etc.) score highly in those areas and will probably outlive the applications I use them in.
I agree with Uncle Bob on one point, though: one has to understand how it works. I remember 10 years ago, when the Java EE world (J2EE at the time) revolved around Struts. Junior developers were brought in, trained in Struts and released in the wild to code Struts applications — most of them didn’t care about knowing the Servlet API underneath! I was shocked that as a software developer, you were not curious enough to understand what happened under the cover.
But you have to stop somewhere. Software development has an history of adding abstraction layers upon layers, to get closer to the domain model. So it sure is nice to know that Vaadin is built upon AJAX and JSON, that produces HTML, that is sent over HTTP. But frankly, I will personally stop there. I don’t need to understand how every bit of memory is handled in the end, do I? I’m afraid dogma doesn’t handle well real-life constraints. That said, the more you know, the better it is…
In conclusion, I’d suggest everyone to make his opinion: try using frameworks and the opposite, and see how it goes depending on the context. But more importantly, don’t take anyone’s opinion to justify your lack of arguments taking one stance or the other.
Opinions expressed by DZone contributors are their own.