Wednesday, December 4

Iterator Design Pattern

Iterator design pattern in java

Lets write an class that has method next() and hasNext() which basically are backbone for iterator design pattern

This Iterator will be iterating over a collection represented by Collection class

Collection class consist of an array of elements that Iterator will be iterating over.

Additionally methods to add and remove elements from array are also available in Collection class

IteratorTestor class consist of all the scenarios where in




  1. First we are iterating over existing list of elements
  2. Then few elements are added to the array and It is again iterated over
  3. Then few elements are removed from the array and then It is again iterated over

Here is the Well compiled code to try this via java code

-=========================================================


public interface Iterator {
   
    public Object next();
    public boolean hasNext();

}


=========================================================


public interface Container {
   
    public Iterator getIterator();

}

=======================================================

This class consist of an inner class MyIterator which basically becomes the part of collection class and
thus it becomes easy for MyIterator class to work on variables of enclosing class. 


import java.lang.reflect.Array;

public class Collection implements Container {

    public
    String[] list = {"element1", "element2", "element3", "element4" };

    public int index;

    @Override
    public Iterator getIterator() {
        // TODO Auto-generated method stub
        return new MyIterator();
    }
   
    public void addElement(Object obj){
        int arrLength=list.length;
        arrLength++;
        String[] newArr =new String[arrLength];
        newArr[arrLength-1]=obj.toString();
        System.arraycopy(list, 0, newArr, 0, list.length);
        list=new String[newArr.length];
        System.arraycopy(newArr, 0, list, 0, newArr.length);


    }
   
    public void removeElement(Object obj){
        int arrLength=list.length;
        arrLength--;
        String[] newArr =new String[arrLength];
        System.arraycopy(list, 0, newArr, 0, list.length-1);
        list=new String[newArr.length];
        System.arraycopy(newArr, 0, list, 0, newArr.length);


    }


    private class MyIterator implements Iterator {

        @Override
        public Object next() {
            // TODO Auto-generated method stub
            if (hasNext()) {
                return list[index++];
            }
            return null;
        }

        @Override
        public boolean hasNext() {
            // TODO Auto-generated method stub
            if (list.length > index) {
                return true;
            }
            return false;
        }

    }

}

============================================================








public class IteratorTester {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Collection repo = new Collection();

        while (repo.getIterator().hasNext()) {
            System.out.println(repo.getIterator().next());
        }

        System.out.println("=================Lets Add Few More Elements========================");

        repo.index=0;
        repo.addElement("NewElemen1");
        repo.addElement("NewElemen2");
        repo.addElement("NewElemen3");
        while (repo.getIterator().hasNext()) {
            System.out.println(repo.getIterator().next());

        }
        System.out.println("===============Lets Remove few elements==========================");

        repo.index=0;
        repo.removeElement("Elemen1");
        repo.removeElement("Elemen2");
        while (repo.getIterator().hasNext()) {
            System.out.println(repo.getIterator().next());

        }


    }
}
===================================================






And this program will print below logs on console :


++++++++++++++++++++++++++++++++++++++++

element1
element2
element3
element4
=================Lets Add Few More Elements========================
element1
element2
element3
element4
NewElemen1
NewElemen2
NewElemen3
===============Lets Remove few elements==========================
element1
element2
element3
element4
NewElemen1

+++++++++++++++++++++++++++++++++++++++

Monday, December 2

Coding Practice to avoid error while using Object references






Let's understand this by example


import java.util.Date;

import java.util.Date;

public class Refree {

    public static void main(String args[]) {

        Date date = new Date();
        Dater coach = new Dater(date);
        System.out.println(coach.date);
        date.setYear(1111);
        System.out.println(coach.date);

    }

}

class Dater {
    public Date date;

    Dater(Date date) {
        this.date = date;
    }
}








This program will print

Mon Dec 02 16:33:48 IST 2013
Mon Dec 02 16:33:48 IST 3011


But in line date.setYear(1111); we only want to change the value of date and not coach instance But this code is changing values of date as well as coach.

So how can we avoid that :

Let's see another version of same program


import java.util.Date;

public class Refree {

    public static void main(String args[]) {

        Date date = new Date();
        Dater coach = new Dater(date);
        System.out.println(coach.date);
        date.setYear(1111);
        System.out.println(coach.date);

    }

}

class Dater {
    public Date date;

    Dater(Date date) {
        this.date = new Date(date.getTime());
    }
}




-->

This program will print

Mon Dec 02 16:36:36 IST 2013
Mon Dec 02 16:36:36 IST 2013



So that's what we wanted..

Command Design Pattern

Consider yourself a referee of a race where you need to give below commands to athletes

Ready -- Athlete to get ready for race
Set  ---
Athletes to all set to run
Go  ---
Athletes to run the race

How can we automate this in java using command design pattern .





Lets consider there is a Race class which defines there action


public class Race {

    public void getReady() {

        System.out.println("getting ready");
    }

    public void set() {
        System.out.println("setting running position");

    }

    public void go() {
        System.out.println("running");

    }
}



Now we need to create there command classes for these three actions

Let's create an interface first which basically will be uniformly implemented by all there command classes

Interface name is Position. It is declaring single method execute()


public interface Position {

    public void execute();
}







Next there command classes

Ready , Set and Go


public class Ready implements Position {

    Race race;   
    public Ready(Race race){
        this.race=race;
    }
    @Override
    public void execute() {

        race.getReady();

    }
}



public class Set implements Position {

    Race race;   
    public Set(Race race){
        this.race=race;
    }
   
    @Override
    public void execute() {
        race.set();
    }

}


public class Go implements Position {

    Race race;   
    public Go(Race race){
        this.race=race;
    }
   
    @Override
    public void execute() {
        race.go();

    }

}



-->


Every command class has one argument constructor which allows Command instances set Race class instance to execute the method on Race class.

Now it is duty of Referee to pass instance of Race class to Commands and Commands will execute() the method invoked inside execute() method.

Here is Referee class


public class Referee {

    public static void main(String args[]){
        Race race=new Race();
       
        Position position1=new Ready(race);
        Position position2=new Set(race);
        Position position3=new Go(race);
       
        position1.execute();
        position2.execute();
        position3.execute();

       
        }

}


Put together all these classes and execute program as java application. That will print below logs on console :



getting ready
setting running position
running



Sunday, December 1

Memento Design Pattern

This pattern talks about restoring the original state at any point of time . For example

I start with knowing the mileage of bike around reference value 80KM/h

I store this value in an string instance say : mileage

My reference value / Original value is 80KM/h

Now I start knowing mileage of various bikes and keep updating the the latest known mileage in same string instace :  mileage

current value might change from 80 to 70 to 50 to 40 to 100 and so on  depending upon the mileage of bikes.

So at any point of time If i want to know the reference value , It's no more there is mileage string.

So how do I make sure that I keep on working on current value as well as be able to retrieve the original value at any point of time.

There might be many ways you ca think across , Memento design pattern suggest a standard way to do that.

Pattern revolves around two contributors

Originator
Care Taker

Originator stores the original value in a non-modified way.
Care Taker takes care of returing current or original value at any point of time
Client directly interacts with Care taker to get current or original value


Now lets see how simple is it to implement it in java :


Originator class stores the original value and it can't be modified .







public class Originator {

    private final String mileage ="80";
   
    public String getFinalInstance(){
        return mileage;
    }

}
CareTaker provides method to get to current or original mileage at any point of time


public class CareTaker {

    private String mileage;
    public CareTaker(String instance) {
       this.mileage=instance;
    }

   public String saveCurrentInstance(String instance){
       this.mileage=instance;
       return this.mileage;
   }
  
   public String restoreDefaultInstance(){
       Originator finalInstance=new Originator();
      return  finalInstance.getFinalInstance();
}
   public String getCurrentValue(){
       return  mileage;
   }
}



-->


And here is our Client who interacts with CareTaker to play with current value and reach original value at any point of time.


public class MementoClient {

    public MementoClient() {
        // TODO Auto-generated constructor stub
    }
   
    public static void main(String args[]){
       
       System.out.println("Some original reference value is already set .......");
        CareTaker instance =new CareTaker("50");
        System.out.println("Let us create an instance with current value ::: 50");
        System.out.println("Lets find out the  original reference  value ");
       System.out.println("it is :::" + instance.restoreDefaultInstance());
        System.out.println("and the current value is :: ");
       System.out.println(instance.getCurrentValue());
        System.out.println("Lets change the value to 40");
        instance.saveCurrentInstance("40");
        System.out.println("Now current value is :::  " + instance.getCurrentValue());
        System.out.println("Let's again change the value to :::100");
        instance.saveCurrentInstance("100");
        System.out.println("Now current value is : " + instance.getCurrentValue());
        System.out.println("Now I want to get to the original  value");
        System.out.println("it is ::: " + instance.restoreDefaultInstance());

    }

}







Executing this application as java application will print below logs on console :

===============================
Some original reference value is already set .......
Let us create an instance with current value ::: 50
Lets find out the  original reference  value
it is :::80
and the current value is ::
50
Lets change the value to 40
Now current value is :::  40
Let's again change the value to :::100
Now current value is : 100
Now I want to get to the original  value
it is ::: 80

================================


 

Friday, November 29

Observer design pattern in java

Lets talk about observer design pattern today--

Lets take in consideration a real time scenarion 

There is a News Control Center that controls current news and subscribers . 

Lets say there are two subscribers Ching and Chong

Ching and Chong are registered by News Control center for current news 

If at any point of time current news are updated News needs to be informed to its all subscribers. 

Subscriber will not keep on checking news all the time If any current news is updated. They will register once for all and News

will ensure that they are timely informed about every new news. So how will that hapend





Ching and Chong will act as observers / listener . News will see If any new news is updated it is informed to its subscribers 


Below Code details this and implement the scenario in java code .

NewsControlCenter Class will hold the main control to apply for subscriber registeration and bring in new news to the agency


==================



public class NewsControlCenter {

    /**
     * @param args
     */
    public static void main(String[] args) {

        Subscriber sub1=new Subscriber("ching");
        Subscriber sub2=new Subscriber("chong");
        News news=new TimesNews();
        news.registerSubscriber(sub1);
        news.registerSubscriber(sub2);
        
        System.out.println("==========news changed======");

        news.updateNews("Narayan traced");
        
        System.out.println("==========news changed again ======");

        news.updateNews("Govt declared prize money on informing Narayan's whereabout.");

        
       
    }

}

==================


import java.util.List;

public interface News {
    void registerSubscriber(Subscriber sub);

    void unRegisterSubscriber(Subscriber sub);

    void updateNews(String news);
    void inform(Subscriber sub);
    void inform(List subs);
    void readCurrentNews();
}


==================








import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class TimesNews implements News {

    String currentNews = "Asharam in Jail";

    List subscribers = new ArrayList();

    @Override
    public void registerSubscriber(Subscriber sub) {
        subscribers.add(sub);
    }

    @Override
    public void unRegisterSubscriber(Subscriber sub) {
        subscribers.remove(sub);
    }

    @Override
    public void updateNews(String news) {

        this.currentNews = news;
        inform(subscribers);

    }

    public void inform(Subscriber sub) {

    }

    public void inform(List subs) {

        for (Iterator iterator = subs.iterator(); iterator.hasNext();) {
            Subscriber subscriber = (Subscriber) iterator.next();
            inform(subscriber);
        }

    }

    public void readCurrentNews() {
        System.out.println(this.currentNews);
    }

}


=====================


-->


public class Subscriber {

    String name;

    public Subscriber(String name) {
        this.name = name;
    }

    public void readNews(News news) {

        System.out.println("Mr. " +name+ ": got this news:::");
        news.readCurrentNews();
}
}


=================



On executing this program as java application . Below logs will be written on console


----------------------------------------------------------

opening news for ::: ching
Asharam in Jail
opening news for ::: chong
Asharam in Jail
==========news changed======
Mr. ching: got this news:::
Narayan traced
Mr. chong: got this news:::
Narayan traced
==========news changed again ======
Mr. ching: got this news:::
Govt declared prize money on informing Narayan's whereabout.
Mr. chong: got this news:::
Govt declared prize money on informing Narayan's whereabout.

-------------------------------------------------------------------------------------

Wednesday, November 20

Once again on visitor's design pattern

I have two employees in my organization : Manoj and Kumar

I wish to have Manoj's employee  data in text format and Kumar's employee data in HTML format

What I would do to get it done :

1. I will create Employee instance called Manoj
2. I will ask Manoj to accept Textformatter as it's formatter
3. Once Manoj accept it , it will ask it's Formatter to apply text formatter on it's data

Code for this is as below :

------------------------------------------

package com;

public class Employee {

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name
     *            the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    String name;

    public Employee() {
        // TODO Auto-generated constructor stub
    }

    public void accept(Formatter visitor) {

        visitor.visit(this);
    }

}
--------------------------------------------







package com;

public interface Formatter {
    
   void visit(Employee emp);
    
   String getResult();
}

------------------------------------------

package com;


public class TextFormat implements Formatter {
    
    String formatting;

    public TextFormat() {
        // TODO Auto-generated constructor stub
    }

    @Override
    public void visit(Employee emp) {
        
        formatting= "formatted the "+ emp.getName()+ " employee data in text format";
    }

    public String getResult(){
        
        return formatting;
    }

}

--------------------------------------------








package com;

public class Test {

    public Test() {
        // TODO Auto-generated constructor stub
    }

    /**
     * @param args
     */
    public static void main(String[] args) {

        Employee emp =new Employee();
        
        Formatter visitor =new TextFormat();
        
        emp.setName("Manoj");
        emp.accept(visitor);
        
        System.out.println(visitor.getResult());
        
    
        
    }

}

----------------------------------------------


Similarly for Kumar to have it's data formatted in HTML format 

1. I will create Employee instance called Kumar
2. I will ask Kumar to accept HTMLformatter as it's formatter
3. Once KUMAR accept it , it will ask it's Formatter to apply HTML formatter on it's data 


Code for this is : 



---------------------------------------






package com;

public class HTMLFormat implements Formatter {

    String formatting;
    
    public HTMLFormat() {
        // TODO Auto-generated constructor stub
    }

    @Override
    public void visit(Employee emp) {
        formatting= "formatted the "+ emp.getName()+ " empolyee data in HTML format";
    }
    
    public String getResult(){
        return formatting;
    }

}

-----------------------------------

package com;

public class Test {

    public Test() {
        // TODO Auto-generated constructor stub
    }

    /**
     * @param args
     */
    public static void main(String[] args) {

        Employee emp =new Employee();
        
        Formatter visitor =new TextFormat();
        
     
        
        visitor =new HTMLFormat();
        emp.setName("Kumar");

        emp.accept(visitor);
        
       System.out.println(visitor.getResult());
        
    }

}


-----------------------------------------



Test class to collectively apply formatters on Manoj and Kumar below Code could be used in single Test class:


----------------------------------------

package com;

public class Test {

    public Test() {
        // TODO Auto-generated constructor stub
    }

    /**
     * @param args
     */
    public static void main(String[] args) {

        Employee emp =new Employee();
        
        Formatter visitor =new TextFormat();
        
        emp.setName("Manoj");
        emp.accept(visitor);
        
        System.out.println(visitor.getResult());
        
        visitor =new HTMLFormat();
        emp.setName("Kumar");

        emp.accept(visitor);
        
       System.out.println(visitor.getResult());
        
    }

}

-------------------------------

Tuesday, October 8

Website Crawler with fork and Join Framework

                Website Crawler with fork and Join Framework 
Here are the classes involved in writing code for this exercise . It can be directly copied and executed using java 7 as fork and Join libraries are available in java only version 1.7 onwards.

Along with these classes you would need HTMLParser jar file , which is used to retrieve links available in a page linked to a particular link. 

Please download htmlparser-1.6.jar file and include in the class path to execute below code


====================================================================

WebsiteCrawler class initiates the logic . It create ForkJoinPool which is used to contain the threads to take up and execute the work stealing algorithm.total work is divided among these threads and is executed is parallel . Thus overall processing is executed faster and multiple processor/core hardware is effectively utilized






import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.concurrent.ForkJoinPool;

/**
 *
 * @author Manoj

  */
public class WebsiteCrawler implements LinkTracker {

    private final Collection linksCrawled = Collections.synchronizedSet(new HashSet());
    private String inputUrl;
    private ForkJoinPool pool;

    public WebsiteCrawler(String inputUrl, int maxThreadCoulnt) {
        this.inputUrl = inputUrl;
        pool = new ForkJoinPool(maxThreadCoulnt);
    }

    private void init() {
        pool.invoke(new LinkSearcher(this.inputUrl, this));
    }

 
   

    public void addVisited(String s) {
        linksCrawled.add(s);
    }


    public boolean visited(String s) {
        return linksCrawled.contains(s);
    }

    public static void main(String[] args) throws Exception {
        new WebsiteCrawler("http://efectivejava.blogspot.in", 50).init();
    }
}




-->


===================================================================

LinkTracker interface provides the basic methods required to execute the link search logic
/**
 *
 * @author Manoj
 */
public interface LinkTracker {

  
    boolean visited(String link);

    void addVisited(String link);
}

import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.RecursiveAction;

import org.htmlparser.Parser;
import org.htmlparser.filters.NodeClassFilter;
import org.htmlparser.tags.LinkTag;
import org.htmlparser.util.NodeList;




==================================================






This is the class where core recursive logic is executed . To divide ,assign and execute the logic recursively this class extends RecursiveAction class and overrides compute() method. compute method is invoked recursively and execute the logic for every link . After visit ,visited link is added to the set and all child URLS found for current URL are added as recursiveAction in the list to be executed by compute() method. 



To understand the code further Please execute this code in debug mode and walk through the flow.



 public class LinkSearcher extends RecursiveAction {

    private String url;
    private LinkTracker tracker;

  
    public LinkSearcher(String url, LinkTracker tracker) {
        this.url = url;
        this.tracker = tracker;
    }

    @Override
    public void compute() {
        if (!tracker.visited(url)) {
            try {
                List actions = new ArrayList();
                URL uriLink = new URL(url);
                Parser parser = new Parser(uriLink.openConnection());
                NodeList list = parser.extractAllNodesThatMatch(new NodeClassFilter(LinkTag.class));

                for (int i = 0; i < list.size(); i++) {
                    LinkTag extracted = (LinkTag) list.elementAt(i);

                    if (!extracted.extractLink().isEmpty() && !tracker.visited(extracted.extractLink())) {

                        actions.add(new LinkSearcher(extracted.extractLink(), tracker));
                    }
                }
                tracker.addVisited(url);
                System.out.println(url);

                invokeAll(actions);
            } catch (Exception e) {
            }
        }
    }
}









Why should override hashcode method while overriding equals method

 Why should override hashcode method while overriding equals method

How do we compare two instances of a class in java 

Lets say there is a class 

public class Employee {

    int age;

    Employee(int age) {

        this.age = age;

    }

    public static void main(String args[]) {

        Employee emp1 = new Employee(10);
        Employee emp2 = new Employee(10);
      
        System.out.println("Are two instances equal?  :" +emp1.equals(emp2));

    }

}


On executing above program , It prints :
Are two instances equal?  :false

Why equals method says that two instances are different although they are instances of same class and have same age?

Reason : While invoking equals method first hashcode() method is executed . If hashcode() method returns different hashcode value for instances being compared equals() method is not called. Different hashcode declares that instances are different and no further comparison takes place.

So Is hashcode values for above tow instances are different ?

Lets see that 

public static void main(String args[]) {

        Employee emp1 = new Employee(10);
        Employee emp2 = new Employee(10);
       
        System.out.println("hashcode value for emp1  " + emp1.hashCode());
        System.out.println("hashcode value for emp2  "+emp2.hashCode());


    }




-->


Executing above method prints 

hashcode value for emp1  327325694
hashcode value for emp2  1657319091


 

So hashcode value returned is different for two instances . Actually hashcode() method works on its inherent algorithm to generate hashcode value of instances . Executing above program again might generate different hashcode values 

Let me execute the above program again and see what values it prints on console 

It prints 

hashcode value for emp1  1025601370
hashcode value for emp2  1578474768

 


So it has it's internal algorithm to generate hashcode value which dynamically generates the hashcode value and we have no control on that..

So how do we make equals method return true flag when comparing two instances of Employee class

let's override equals method as below 

  public  boolean equals(Object obj){
       
       return this.age==((Employee)obj).age  ;  
    }
 

Here Object class equals method is overridden . Now equals method is customized so it will declare two instances equal if their ages are equal . So emp1.equals(emp2) should return true 







But bigger barrier is hashcode() method . This method does not let the call go to equals() method . It returns false based of different hashcode value for two instances . 

So what do we do to make the call reach equals() method?

 Equals() method can be invoked only if hashcode value for two instances being compared are equal . So can we customize hashcode() method to make it happen . Let's try doing that 

     public int hashCode() {
         return this.age;
     }
 
Now executing hashcode value will print 
 
hashcode value for emp1  10
hashcode value for emp2  10

So hashcode values are equal. Hashcode method itsself can't decide in this case If 
two instance are equal and to decide that equals() method is invoked. 
 
Thus It is must to override hashcode() method to make equals() method invoked. 
 
So we can conclude 
 
If equals() method is customized and overridden then it make it work as we expect It is 
must to override hashcode method in a way to make call to equals() possible. 

 







Sunday, October 6

How to make a website SEO friendly , Search engine optimization

                         How to make a website SEO friendly , Search engine optimization


Page Title
Your title should be from 20 to 70 characters length. However up to 120 characters can be considered as correct.
Make sure that title is correct and includes most important keyword.
Each page should have it's own, unique title.

Meta Description
Meta description should be from 100 to 160 characters length. However up to 200 characters can be considered as correct.
Use all characters to describe your page using most important keyword.
Each page should have it’s own, unique description.
Meta description usually shows in search engine results as a description of page and it should encourage to visit your site.

Meta Keywords
Meta keywords has no influence on website positioning.
You can remove all meta keywords or limit them to only few describing your content.

Meta Robots
Meta tag robots has crucial impact on page indexing by search engine robots.
Value "noindex" prevents from indexing of page. Value "nofollow" prevents robots from following all links at page.
Most common and default (if empty) values are index, 

Encoding
 Encoding has an impact on the correct display of special characters.
Popular encodings are UTF-8, Latin1, ISO-8859-2 etc.
Encoding has no influence on website positioning, but incorrect encoding can cause problems with display special characters.
Body Content

Words and Chars
 Make sure that the text on page was not less than 250 words.
 
Text / HTML Ratio
The TEXT / HTML ratio is the ratio of the number of characters of plain text to the page's HTML code, expressed as a percentage.
The higher the number, the greater amount of content is on your site, and lesser HTML code.
A value below 10% means that there is too little text or that the HTML code is "littered" or negligent.
Make sure that the TEXT / HTML ratio is not below 10%.

Headers
H1
H2
H3
H4
H5
H6
Headers are very important factor of on-page optimization.
Correct document should contain most important

and second-level

.
Remember to insert important keyword in header.


Bolds
 The and bold type indicate the important keywords on the page.
Search engines take into account emphasized keywords that are in the text.



-->


Images
 Images enrich the content of the website.
No images on the page may be a warning signal against spam, or the page is of low quality.
Publish interesting pictures, photos or diagrams related to the content of the page.
Using the ALT attribute describe accurately each picture.

Frames
 Frames can cause problems to search engines and make your website works slow.
Avoid use of frames on websites.

Internal and External Links
External Links
1                    External Links
Outbound links (external links) are all links leading outside your website.
It is worth to link to other sites that contain high quality content related to the theme of your site.
Do not link to sites which you do not trust, in particular the spam pages.
Limit the number of outbound links to a maximum of 15 links.
Internal Links
2                    Internal Links
Internal links are any links pointing to the other pages of your website.
By placing links to other pages you are reinforcing internal linking and strengthening the usability of your website.
Always link to the most important pages of your website.

Additional Files
Robots.txt
The robots.txt file instructs search engine robots by allowing or restricting access to selected folders and pages of your website.
The robots.txt file has a huge impact on the correct page indexing in search engine results.
Make sure your website has a valid robots.txt file.

Sitemap.xml
The sitemap.xml file should contain a list of all pages of your website that need to be indexed by search engines.
Sitemap.xml file informs the search engine about relevant pages on your site, their latest update and significance in the context of the entire site.
Ensure the correctness of sitemap.xml

Social Media Signals
Facebook Likes

The number of gained "Likes" can have a positive impact on the position of your site in search results.
Install the Facebook Like button on your website and encourage your users to like your site.
Facebook Shares






By sharing your site with friends on Facebook you have a chance to gain new visitors. A large number of "shares" may have a positive impact on the position of your site in search engines.
Google +1

The number of gained Google +1 has a positive impact on the position of your site in search results.
Install Google +1 button on your website and encourage your users to click on +1.

HTTP Headers
HTTP headers is the server return information, not visible on the website.
SEO audit can be performed only on sites that have an HTTP 200 OK header, which indicates proper functioning of the page.
Any other value of the HTTP code prevents from page positioning.

Domain and Server
IP Address
IP Address has no influence on website positioning.
On one IP address can work hundreds of different websites.
Avoid sharing IP address with spam websites.
Name Servers
DNS servers has no influence on website positioning.
Like IP address, many websites can use the same DNS servers.
Avoid sharing DNS names with spam websites.
Server Geolocation
 Geographical localization of server has no direct influence on website positioning.
Use hosting companies located in regions where you are making your business.