eXtropia Studios Software Development

At eXtropia Studios, software development is both a science and a passion. We actively research all aspects of the software production cycle, constantly seeking improvement, constantly working outside the box.

Java Singleton

public class SingletonClass {
  public static SingletonClass getInstance() {
    if (SingletonClass.instance==null) {
      SingletonClass.instance = new SingletonClass();
    }
    return SingletonClass.instance;
  }
	
  private SingletonClass() {
    // private constructor prevents external instansiation
  }
	
  private static SingletonClass instance = null;
}

PHP5 Singleton

class SingletonClass {
  public static function getInstance() {
    if (self::$instance==null) {
      self::$instance = new SingletonClass();
    }
    return self::$instance;
  }
	
  private function __construct() {
    // private constructor prevents external instansiation
  }
	
  private static $instance = null;
}

C++ Singleton

class SingletonClass {
public:
  static SingletonClass* getInstance();
private:
  SingletonClass(); // private constructor
  static SingletonClass* instance;
};

SingletonClass* SingletonClass::getInstance()
{
  if (!instance) {
    instance = new SingletonInstance();
  }
  return instance;
}

SingletonClass* SingletonClass::instance = 0;

Javascript Singleton

function SingletonClass {
  // class definition here
}

SingletonClass.instance = null;

SingletonClass.getInstance = function() {
  if (!SingletonClass.instance) {
    SingletonClass.instance = new SingletonClass();
  }
  return SingletonClass.instance;
};

Creating Object Oriented Database Interfaces in PHP5

interface RecordSet {
  public function fetch();
  public function fetchAssociative();
  public function fetchObject();
  public function getFieldSpecifications();
}
interface RecordSetBuffered extends RecordSet {
  public function numRows();
  public function numColumns();
  public function setCursor();
  public function getCursor();
}
we like -rw-r--r-- 1 root web 946 Jun 21 2009 avatar graveyard -rw-r--r-- 4 root web 2668 Jul 2 2009 the leander -rw-r--r-- 3 root web 2450 Jun 17 2009 weebls stuff login>_

eXtropia Studios Software Development

At eXtropia Studios, software development is both a science and a passion. We actively research all aspects of the software production cycle, constantly seeking improvement, constantly working outside the box.