(Mar-04-2022, 11:18 PM)Frankduc Wrote: when you guys comes with sopheticated answers like this.
I don't think the code I showed was particularly sophisticated, but I can appreciate you may not be familiar with testing or enumerations. The main point I want to get across now though is that the
Temperature
class I wrote (that passed my tests) was simple. Why simple? Because it represents a single idea: what it means to be a temperature - there's a value and a unit and one can convert between units. Your class, on the other hand, is complicated. It mixes together the idea of what it means to be a temperature and displaying a temperature on a GUI. That makes it harder to understand and harder to change if you needed to - with multiple things going on in a class, if you change one thing you risk breaking another. Try to separate out different ideas like this - remember the Unix philosophy of "do one thing and do it well".