I have an scenario with objects moving around on a coordinate system. I thought of using java.awt.Point in my model classes, as it provides all the functionalty I need (location representation, translate, distance computation).
But using classes of java.awt in my model feels somehow wrong. But rewriting same funcionalty can't be the answer either.
So my question is: Is it okay to use such graphic related classes in model classes or is this bad style? In case of bad style, what would be a good alternative approach?
If you plan that one day to reuse the model on other platforms like Android then it is really not a good idea.
In general, I agree that java.awt classes shouldn't be part of the model of an application. I think I would create my own Point class and define the methods I need in there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With