This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of TensorFlow 2.0 in Action and have Thushan Ganegedara on-line!
See this thread for details.
Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

What is the difference between creating a library ,a framework and a reusable component ?

 
Ranch Foreman
Posts: 1809
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between creating a library ,a framework and a reusable component in Java ?
Thanks
 
Saloon Keeper
Posts: 7393
66
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Library and a Framework are both built from sets of related reusable components. Generally speaking, a Framework is an encompassing set of classes that is designed to call your classes and methods. Not the other way around. So, typically, a Framework contains the main() method. A Library, on the other hand, is a set of related components that your application will call and make use of. In that case it's your app's code that is responsible for providing a main() method. Reusable components can be any class that encapsulates the data and behavior in a way that it can be used in one or more places in an application. Reusable components make things clearer and less redundant and are often more robust because they can be tested independent of the application.
 
Monica Shiralkar
Ranch Foreman
Posts: 1809
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Can a library also be a reusable component ?
 
Carey Brown
Saloon Keeper
Posts: 7393
66
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I consider Libraries and Frameworks as collections of reusable Components more than Components themselves. This may be open to interpretation.
 
Greenhorn
Posts: 18
3
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a classic question, but I often find it helps to think about practical examples.

  • A framework would be something like Java Enterprise Edition, or Spring, where pretty much all your code is tightly coupled to the framework, because you are coding to the framework's requirements and it calls your code (as Campbell points out).  You cannot easily swap one framework for another e.g. from JEE to Spring - without a lot of re-writing.  And often you can't mix two different frameworks together without a world of pain.
  • A library is something that you call from your code e.g. a Maths or DateTime library or a JSON parser etc, where it's easy to swap one for another, and all you have to change is the specific call to the library function because the library does not affect the rest of your code.  You can also mix and match different libraries for different things.


  • I think JEE and Spring have both evolved over the years to allow greater flexibility in how you use their frameworks (indeed, Spring was invented as a deliberate effort to avoid the complexity and tight coupling of J2EE), but you still end up with a lot of coupling between your application and the framework, whichever one you use.

    Meanwhile, web development seems to be full of frameworks too, which seems like a nice money-making exercise for some folks...
     
    Monica Shiralkar
    Ranch Foreman
    Posts: 1809
    9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks
     
    Saloon Keeper
    Posts: 22668
    153
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    In short as a general rule, you might define one or more re-usable Components in a Library. A Framework might contain multiple libraries.

    A Framework is a collection of resources working towards a common goal. For example, Spring provides a common core that creates and manages JavaBeans. It has Modules, which are collections of libraries intended for a specific abstract purpose, such as Spring Data for persistent storage, Spring Security, Spring Scheduler and the like. Then within those logical modules are physical modules like Spring JDBC, Spring JPA and so forth, each of which comes with its own set of libraries. Spring piles on the layers pretty deep as you can see.
     
    Monica Shiralkar
    Ranch Foreman
    Posts: 1809
    9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Tim Holloway wrote:In short as a general rule, you might define one or more re-usable Components in a Library.



    Does that mean that if library will be consisted of a number of jars, then some of these jars may constitute a reusable component ? What exactly differentiates a library from reusable component?
     
    Marshal
    Posts: 70689
    288
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    What distinguishes a library from a book?
     
    Monica Shiralkar
    Ranch Foreman
    Posts: 1809
    9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Campbell Ritchie wrote:What distinguishes a library from a book?



    Library is a group of jars to do something whereas book is for reading to get some knowledge.
     
    They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    reply
      Bookmark Topic Watch Topic
    • New Topic