Apply operations efficiently using Command pattern | Oracle Interview Question