scala design pattern