4 ms·
What (from a code organization perspective) might work better in practice is: water.heat(stove); because it's the water that's being changed and change sh
by username56283 12y ago
What (from a code organization perspective) might work better in practice is:
water.heat(stove);
because it's the water that's being changed and change should be encapsulated. On the other hand, the stove may also change in the process. In fact, the water and the stove do things to each other. Then what makes either of the two options more appropriate? Similar issues arise with a method called sendMessage; is the object having this method now supposed to send a message or to receive a message?
- sbov 12y agoWhat we actually need is to be able to use different heating algorithms dynamically. To achieve this we will use the strategy pattern, so you end up with: heatingStrategy.heat(water, stove);
- username56283 12y agoWhat methods is this heating strategy going to call on water and stove? Consider for example that the stove builds up rust. Therefore it needs to know the properties of what's inside. Is the heating strategy going to tell it that?