DEV Community

Discussion on: Nothing is wrong about a framework - except what you might think it is

Collapse
 
kspeakman profile image
Kasey Speakman

I generally look at frameworks as: they require my code to fit a certain shape to use them (e.g. my code has to inherit a class or implement an interface). Whereas I look at a library as: I can substitute a chunk of common code with a call to the library function/object. From this perspective, frameworks are restrictive whereas libraries are freeing.

Collapse
 
dguhl profile image
D. Guhl

If you are the only one writing code, that's great. But that way you rarely create maintainable software or follow concepts which make code more clean and structured. There is nothing wrong in following a framework's paradigm, as it represents publicly shared, interchangeable knowledge, while every custom structured program which merely uses some libraries is - knowledge-wise - a vendor lock-in to everyone who would probably like to contribute.

Writing code in a way which is widely understood by developers as it bows to publicly available best practices and standards can lower the threshold keeping people from filing a pull request to your project.

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

I used to think this way too. But maintainable software ends up depending on replaceable and refactorable pieces. If the framework doesn't fit some use case, you can't just refactor it. Even if you can (or if the framework provider does and releases a new version with breaking changes), you then have to refactor every bit of code that coupled itself to the framework. With libraries you can add the functionality as a separate / optional part. (Whether a library author does or not is perhaps another matter.) The most reusable pieces of software are structured as libraries with optional functionality rather than required abstractions.

I'm not sure how you got vendor lock-in from libraries? I wasn't discussing any vendors, and the library may even be internally created ones. E.g. Amazon maintains it's own infrastructure services libraries to make it easy for teams to access the Amazon infrastructures they need.

All that said, I do use some external frameworks in absence of other reasonable choices. And sometimes frameworks are a good answer to certain problems. Internally, I try to avoid developing frameworks for my apps. Because I tried it in the past and paid for it later. :)