code demo for design pattern