Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using java.awt.Point in model classes - bad coding style?

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?

like image 818
kobo Avatar asked Jan 15 '23 13:01

kobo


1 Answers

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.

like image 76
Dan D. Avatar answered Jan 31 '23 01:01

Dan D.