Replies: 1 comment
-
I think most people define library vs. framework in this way: Library: your code is in charge of the lifecycle of objects (creating, using) that the library supplies. Library doesn't care what code calls it. Framework: the framework is in charge of the lifecycle of objects, often requiring the use of an "IoC container" to keep track of all the objects that it creates (in combination with Dependency Injection). Sometimes you are required to implement/extend classes for use by the framework (though these days annotations replace many of those requirements). There may be parts of a Framework that can be used like a library, e.g., I think the Collection "Framework" is not a framework, it got that name because there is some extensibility, but it's really a library. As for when to use one or the other, while an application codebase can use many libraries all at once, you probably want to stick with a single framework (if any) for that application, otherwise the frameworks will be "fighting" for which one is in charge of creating and accessing your objects. For example, your app might use the Spring Framework, along with libraries for accessing messaging systems, databases, etc. It's unlikely you'd be very happy if you tried to also use the Micronaut framework at the same time. |
Beta Was this translation helpful? Give feedback.
-
Also why Collection is called a framework in Java, not a library although we use it as a library?
Beta Was this translation helpful? Give feedback.
All reactions