mardi 23 mai 2017

WPF controls and C# patterns

I have a slider. I also have three buttons. Each button it titled as follows, respectively: "Cesius", "Fahrenheit", "Kelvin".

I thought to implement a factory pattern in an interface and then have three separate classes called toCelsius, toFahrenheit, toKelvin.

However, I realized that I might need to add some other kind of temperature measure, a fourth kind of unit, a fifth kind of unit, etc (i.e. a fourth button, a fifth button, etc).

So I would need to alter the interface. I would also need to add to each separate Class and to cater for the new additional units.

Is there a more elegant pattern I could use, instead of factory?

I'm teaching myself C# and it goes slowly. I'd appreciate you pointing me in the right direction so I can do some research on the suggested pattern to use.

Thanks.

Aucun commentaire:

Enregistrer un commentaire