Implementation of popular javascript design patters