Featured

REST

What is REST stands for? Representational State Transfer
OK first lets consider what is REST, REST is a architecture which based on web standards and uses HTTP protocol for data communication. REST architecture treats every content as a resource. we can get text files, html pages, images, dynamic data etc. as resources. Each resource is identified by URIs. (Uniform Resource Identifier) REST uses like text, JSON and XML to represent a resource. ¬†Now you will think what is this URI, resource ūüôā
we will discuss more about those later.

OK now lets talk about RESTFul web service. Before talk about RESTFul web service we have to know what is a web service?¬† Simply we can say, web service is a collection of protocols and standards used for exchanging data between applications or systems.¬†why we want web service, lets think we have two software applications which written in various languages and running on various platforms. So how can we exchange data between those applications? OK now web services come to picture ūüėÄ

Now it is very easy to say what is RESTFul web service. If we use REST architecture for a web service we can call it RESTFul web service. Please keep in mind REST is not a programming language or something it is a ARCHITECTURE ūüôā

Above we said REST uses HTTP protocol for data communication. RESTFul web services communicate using HTTP request and HTTP response. A client sends a message in form of a HTTP request and server responds in form of HTTP response. we call this technique as Messaging.
HTTP request has five major parts.

Verb Р                    This indicate HTTP methods such as GET, POST, DELETE, PUT etc.
URI Р                      we can identify the resource on server using this.
HTTP Version Р    This indicate HTTP version. eg:- HTTP v1.1
Request Header РThis contains metadata for the HTTP request message as key-value                                          pairs. eg:- client type, format supported by client, format of message                                        body etc.
Request body Р     Message content or Resource representation.

HTTP response has four major parts.

Status/Response code –¬†Indicate Server status for the requested resource. eg:- 404 Not ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† found
HTTP version
Response Header Р      eg:-content length, content type, response date, server type etc.
Response body Р          Response message content or Resource representation.

OOOOOK I think now we know something about REST ūüôā Can you remember, above we mentioned about URI ?
Now you know URI stands for Uniform Resource Identifier. URI identifies each resource in REST architecture. Purpose of an URI is to locate a resource(s) on the server hosting the web service.
This is the format of URI

<protocol>://<service-name>/<ResourceType>/<ResourceID>
eg:- http://www.example.com/customers/12345

Let’s think we want to read a customer with ID# ¬†12345, We can use,
GET http://www.example.com/customers/12345

Ohhh wait, What is this “GET”? Did you see that “GET” or you just read it ūüėÄ
I think you can remember that we have discussed about five major parts of a HTTP request. ??? scroll up and see ūüôā
In that Verb part, It indicates HTTP methods such as GET, POST, DELETE, PUT etc.
OK now you know what that “GET” is. The following HTTP methods are most commonly used in a REST based architecture. we use HTTP methods to map CRUD(create,retrieve,update,delete) operations to HTTP requests.

GET
we can use GET for retrieve information. GET method is idempotent. ūüôā another new word. idempotent is¬†used more comprehensively to describe an operation that will produce the same results if executed once or multiple times.¬†
simply we can say, if we execute GET method with same parameters many times, we get same result. No effects.
eg:- To read a customer with Customer ID# 12345:
        GET  http://www.example.com/customers/12345  

POST
Request that the resource at the URI do something with the provided entity.
POST is used to create a new entity, but it can also be used to update an entity.
eg:-To create a new product.
      POST http://www.example.com/products

PUT
Store an entity at a URI. PUT can create a new entity or update an existing one. A PUT request is idempotent. Idempotency is the main difference between the expectations of PUT versus a POST request.

DELETE
Request that a resource be removed; however, the resource does not have to be removed immediately. It could be an asynchronous or long-running request.

Ok now you got some idea about REST and later we can talk about more details about these HTTP methods and other things ūüôā

Advertisements

Java ArrayList

Ok today we gonna talk about Java Array List. Array List is very similar to array and we can store elements sequentially and access elements by indexed position. But the main difference between Array and Array List is, Array List is dynamic. It means It’s size can grow and shrink. but Array have a fixed size. OK got it? ūüôā It was a simple definition of Array List. Let’s know more about Array List.

Let’s look a simple code

import java.util.*;

class AList{
          public static void main(String args[]){
 ArrayList<String> al=new ArrayList<String>();//creating arraylist
 al.add("somba");//adding object in arraylist
 al.add("tole");
 al.add("gune");
 al.add("toke");

Iterator itr=al.iterator();//getting Iterator from arraylist to traverse elements
   while(itr.hasNext()){   //also we can use for loop for traverse elements
 System.out.println(itr.next());
 }
 }
 }

In this code first we have imported java.util.* or we can import just java.util.ArrayList  class.

ArrayList<String> al=new ArrayList<String>();

Here we create new Array List object “al” and we give the object type as a String. If you want to create an Integer ArrayList you can do like this.

ArrayList<Integer> al=new ArrayList<Integer>();

Here we put “Integer” ¬†integer class and not a “int” premitive.

Why we use ArrayList ?
* It can grow dynamically.
* It provides more powerful insertion and search mechanisms than arrays.
* Java ArrayList class is non synchronized.

when we talk about arrayList, I think we should consider about Genaric collection.
Now you will see what is genaric. ūüôā

Before genaric is introduced we can store any type of objects in collection. It means non-generic. But in “genarics” , forces java programmer to ¬† store specific type of objects.

Before genarics, here we have to do type casting.

List list = new ArrayList();
list.add(“hello”);
String s = (String) list.get(0);//typecasting

After genarics, here we don’t need to typecast the object.

List<String> list = new ArrayList<String>();
list.add(“hello”);
String s = list.get(0);

In generic collection, we specify the type in angular braces. Now ArrayList is forced to have only specified type of objects in it. If you try to add another type of object, it gives compile time error.

 

How to install xampp on ubuntu

Hi ¬†Today my friend asked me how to install xampp on ubuntu. Ohhh I have installed it before but ¬†I forgot it ūüėÄ ¬†So I thought it is better to write it…. ūüėÄ

First go to below this link and download xampp instaler
https://www.apachefriends.org/index.html

Screenshot from 2016-05-24 14:52:44

Screenshot from 2016-05-24 14:59:51

Ok then we have to go to  .run file location and give permission for that file.

Screenshot from 2016-05-24 15:16:21

Then run installer file
run this command

./xampp-linux-x64-installer.run

then it will show this

Screenshot from 2016-05-24 15:45:35

 

Screenshot from 2016-05-24 15:48:17

Screenshot from 2016-05-24 15:49:00

Screenshot from 2016-05-24 15:50:51

OK Now we have installed xampp. ūüôā and then we have to run below command to start lampp

sudo  /opt/lampp/lampp  start

and to stop

sudo  /opt/lampp/lampp  stop

Screenshot from 2016-05-24 16:04:45

If there is any permission problem ūüėÄ give permission
sudo chmod 777 htdocs

Screenshot from 2016-05-24 16:16:19

This worked for me ūüėÄ thank you !!!!

 

How to install mobile partner in ubuntu

Hi guys today I found another small thing in Ubuntu ūüôā Actually It was told me by my friend Kalinga ūüôā Thanks bro..
Today I knew about how to install mobile partner in Ubuntu. So I am going to tell you too how to install modem-manager-gui

To add the PPA, run these commands in terminal: (now don’t ask me what is PPA ūüėÄ search it )

sudo add-apt-repository ppa:linuxonly/modem+manager+gui
sudo apt-get update

Then run this command
sudo apt-get install modem-manager-gui

Ok i think now you have¬†modem-manager-gui¬† in your ubuntu environment because It worked for me ūüôā
Thank you !!!

 

 

What is the difference between Procedural Programming and OOP Programming ?

In Procedural Programming we use a list of instructions to tell the computer what to do and here we divide the program into small parts called functions. In PP, If you want a computer to do something, you should provide step-by-step instructions on how to do it and it follows top down apporach. It means Procedural Programming takes on applications by solving problems from the top of the code down to the bottom. The main issue in PP is that if a developer wants to edit a code he must edit every line of code that corresponds to the original change in the code.

Object-oriented Programming is a programming language that uses classes and objects to create models based on the real world environment. An object is a component of a program that knows how to perform certain actions and how to interact with other elements of the program and objects are the basic units in OOP. In OOP It is easy to edit and maintain the code. Also other developers can understand the program after development.

A method in OOP is like a procedure in PP and method is part of an object.In object-oriented programming, you organize your code by creating objects, and then you can give those objects properties and you can make them do certain things.

  • Object-oriented Programming uses methods and Procedural Programming uses procedures.
  • Object-oriented Programming uses objects where Procedural Programming uses records.
  • Object-oriented Programming uses classes where Procedural Programming uses modules
  • Object-oriented Programming uses messages where Procedural Programming uses procedure calls.
  • In PP, Most function uses Global data for sharing that can be accessed freely from function to function in the system and¬†In OOP, data can not move easily from function to function,it can be kept public or private so we can control the access of data.
  • PP does not have any proper way for hiding data so it is less secure¬†and¬†OOP provides Data Hiding so provides more security.
  • PP follows Top Down approach¬†and¬†OOP follows Bottom Up approach.
  • In POP, Overloading is not possible and¬†In OOP, overloading is possible in the form of Function Overloading and Operator Overloading.

I saw a simple example about PP & OOP when I searched ¬†ūüôā

“

A simple way to compare both programming methods is to think of Object-oriented Programming as  learn to read picture book. As children see pictures of simple objects like a house or picture they know that throughout the book when they see a picture of the house it represents the word house. The children can then read through the book as words are substituted throughout the story with pictures.

In Object-oriented Programming the classes could represent the pictures in the learn to read books. A house could represent a class and anything the developer wants to have included to describe that house like the color, size, number of bathrooms etc.

In Procedural Programming the learn to read book would be words on the page without pictures to help guide the young learner through the book. If the story was changed in the beginning of the book it could disrupt or make the story later on in the book not make any sense. Although learning to read the book would make programming with Procedural Programming simple, it would make it difficult for other readers in the case of the book or programmers in the case of Procedural Programming to add to the story.

“

How to install google chrome on ubuntu

Ok get the terminal and again you have to only give some commands…..

First you have to give the link for chrome.
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

Screenshot from 2016-04-09 09:00:32

Ok now wait…. It is downloading…

Screenshot from 2016-04-09 09:03:21

After that enter below command…
sudo dpkg -i google-chrome*

Screenshot from 2016-04-09 09:07:51

Ok now you have installed chrome. But if it will give error try this force command.

sudo apt-get install -f

Screenshot from 2016-04-09 09:12:38

This steps worked for me. Try these and thank you….. ūüôā

 

How to install sublime text-3 in ubuntu

Ok first get the terminal……

Screenshot from 2016-04-06 13:53:21

It is very easy.. now follow this commands…..

  • sudo add-apt-repository ppa:webupd8team/sublime-text-3
    now it will ask your password. so give it :D
    Then again you will have to press enter. wait....
    ok now enter below command.

 

  • sudo apt-get update

    wait and enter this command

  • sudo apt-get install sumblime-text-installer

    Ok now you have installed sublime text editor…..