code samples in various design patterns