Javascript architectural solutions and Code reuse patterns