Tuesday, November 22, 2016

Role of Java API/Interfaces in Object Oriented Programming World!W

As we know ,Java is full of rich inbuilt library and thats what makes java mostly used object oriented programming langauge!
In this blog, I am going to discuss Role of java API's in programming world.
Lets illustrate this with few examples which clearly lays out the role of java API's.

Example 1:

JAX-RS API(JAVA API for Restful Web services)::
This is Specification for developing Restful API applications.
Let we desgined A Rest API Application using this API and Jersey(One of Impl. of JAX-RS) and assume we want to move to some other implementation of JAX-RS apart from Jersey,then how much time it will take to learn some other implementation like RestLet or RestEasy of JAX-RS API. The answer is-Since All of these implementations(jersey,RestEasy,Restlet etc) follows common set of Instrcutions imposed by JAX-RS, So Next time if we want to switch to some other Impl. of JAX-RS ,Simple plug in that Impl. JAR and our old code still works so that our code is portable across different Implementations of JAX-RS. In Other words ,our application code is not tightly coupled with any of Implementations of JAX-RS.

.Example 2:

JDBC API:

This API actually exposed BY Sun People for Java Programmers to be used in persistance Layer of Enterprise Application.There are lot of Implementations for this API given by Different Database server vendors like Oracle,MySql, MS SQL Server,Apache Derby,PostGres etc.
Think about let we using JDBC Application code to connect Oracle DB server, how much time it will take to learn if we want to connect to other DataBase server like Apache derby or Postgres DB server?
The answer is: The moment we learned to connect to one DataBase , we learned to connect to all DataBase servers because All these DB servers Drivers follows a common set of instrcutions or specifications which is nothing but JDBC API.So next time if we want to connect to other DataBase server,just plugin the that server driver jar in our application classpath and old code still works.So in this way our application code is completely loosely coupled with DB Server.

Example 3
JEE Specification:

This is Java Enterprise Edition Specification imposed by Sun people for Programmer to develop web based applications and for Application/Web servers vendors to implement.
Let we developed an Web Application using this Specification and deployed in some server.The advantage of API is: Same application we can deploy in Any of web or application server as all of these server containers implements a common set of specification which is nothing but JEE Specification.Hence our application code still works irrespective of which web or application server we using .As long as sever container implements or follows JEE specifcation ,our code is portable across diff. Web/App. servers.
Regards
Rahul Rajput