js - design patterns