sample code of design pattern