some code about design patterns