Understanding how protocols work in combination with classes