add code for factory and observer patterns