Friday, November 16, 2012

Facebook Edgerank Algorithm Explained

the Edgerank algorithm is used in Facebook to determine the order of posts that should be shown on a user's Top News feed. 

Sunday, November 4, 2012

Flyweight Design Pattern

The flyweight design pattern is used to dramatically increase the speed of code when using many similar objects.

To reduce memory usage the flyweight design pattern shares Objects that are the same rather than creating new ones.

Bridge Design Pattern

This pattern is used to build a group of classes that slowly adds functionality from one class to the next. 

Facade Design Pattern

English: Author: Alcides Carlos de Moraes Neto...English: Author: Alcides Carlos de Moraes Neto (wikipedia.10.alcides@spamgourmet.com) (Photo credit: Wikipedia)
The Facade pattern simplify methods so that most of the processing is done in the background. In technical terms it decouples the client from the sub components needed to perform an operation.


Iterator Design Pattern

The Iterator design pattern illustration, UML ...The Iterator design pattern illustration, UML diagram. (Photo credit: Wikipedia)
The iterator pattern is used to access objects that are stored in many different types of collection.
This is done by creating a common interface that all the different collection classes share. Then an iterator is provided to traverse the objects they contain.

Because all different Collection classes share a common interface they can be treated polymorphically and it eliminate duplicate code.


Below is the video tutorial for the Iterator pattern


State Design Pattern

English: UML Class Diagram of the State Design...English: UML Class Diagram of the State Design Pattern (Photo credit: Wikipedia)

Below is the video tutorial on State Design Pattern

Command Design Pattern

The UML diagram describing relations between o...The UML diagram describing relations between objects of the Command design pattern. (Photo credit: Wikipedia)
The UML diagram which describes the structure ...The UML diagram which describes the structure of the Command design pattern. (Photo credit: Wikipedia)


public interface Computer {
   void start();
   void shutdown();
}

public class Laptop implements Computer {
   public void start() {
       System.out.print("Laptop is started");
    }

    public void shutdown() {
       System.out.print("Laptop is shutdown");
    }

}

public interface Command {
   void execute();
   void undo();
}

public class StartLaptop implements Command {
   Computer theComputer;
   
    public StartLaptop (Computer newComputer ) {
        theComputer = newComputer;
    }

    public void execute() {
        theComputer.start();
    }
    
    public void undo() {
        theComputer.shutdown();
    }         
}

Below is the video tutorial about the Command pattern. 


Singleton Design Pattern Tutorial

Singleton Pattern is used to prevent instantiation of an object more than once.

Saturday, November 3, 2012

Abstract Factory Design Pattern

Factory Design Pattern

Factory design pattern is used to define the class of an object at runtime. It allows encapsulating object creation to keep all object creation code in one place. (separation of concerns)

You cannot instantiate an abstract class. It is just there to facilitate polymorphism.

Basic Principles of Object Oriented Technology