code for design pattern