tutorial design pattern in java