Design patterns in java