Skip to main content

Posts

Showing posts from April, 2017

Data-tables over traditional HTML tables

This blog post is about using datatables v0.5 ( http://l-lin.github.io/angular-datatables/archives/ ) with Angular 1. We can easily feed data using angular into a datatable from  https://datatables.net/  which is built using jQuery. Why data-tables ? There are many benefits of using data-tables.  One major benefit is if you are not a UI/UX person, and don't want to spend much time styling, you can still give users a good experience by just including a data table. You will not have to put effot into implementing search or sort. It is by default provided.  Pre-requisites In order to use datatables you will need the following dependencies to be added to your project. jQuery datatables.net datatables.net-dt angular-datatables You can use npm, bower or the cdns to include these in your project. When using the bower component for angular-datatables I encountered a problem since the datatables we are using is an old version. To get over th...

Flexibility of Serializability in Java

What is Serialization in Java? The mechanism where an object state is represented as a byte stream. Here, all object data as well as the information regarding the object such as its type are also included. Deserialization, which is the reverse mechanism can be used to recreate the same object. Why is Java Serialization important? It is JVM independent, meaning that the object can be serialized at one platform and deserialized at another. Therefore it is used ti transfer object state across networks. How to serialize an object? Implement java.io.Serializable interface All fields must be serializable. (If a Java Standard class implements java.io.Serializable interface, then it is serializable). Whichever fields you do not wish to serialize should be marked as transient. import java.io.Serializable; class User implements Serializable { public int uid; public String name; public String address; } Now, the class is eligible...

HATEOAS for REST APIs

What is HATEOAS? HATEOAS stands for Hypermedia as the Engine of Application State which is a constraint of the REST application architecture. REST APIs has no service definition and no formal documentation. The best REST APIs don't need any documentation. Just like websites have navigation from one page to another, REST APIs are able to do the same using HATEOAS. In HATEOAS the response will carry links that provide links as to where to find the related resources. This will let clients know all the things they can do with the received response and make the response navigable. Eg: An user object may contain the URI to itself.  { " name " : " John Doe " , " links " : [ { " rel " : " self " , " href " : " http://localhost:8080/users/1 " } ] } 'rel' attribute here defines the relationship. If we take a status object of a particular social network site, it could...