In java (and many other programming language), there are often structure to deal with graphic element : Colour, Shape, etc. Those are most often in a UI toolkit and thus have a relatively strong coupling with UI element. Now, in the domain of my application, we often deal with colour, shape, etc, to display statistic information on an element. Right now all we do with it is display/save those element with little or no behaviour. Would it make sense to avoid reinventing the wheel and directly use the structures in java.awt.* or should I make my own element and avoid a coupling to this toolkit? Its not like those element are going away anytime soon (they are part of the core java library after all), but at the same time it feel weird to import java.awt.* server side. I have no problem using java.util.List everywhere. Should I feel different about those class?What would be the recommended practice in that case?
Should I use structure from a core library graphic toolkit in my domain?
java;domain model;coupling
I would apply YAGNI here and use the structures from the standard library, however I would be careful to ensure all parts of the domain using this stuff are as close together in the system as possible. This will make searching out the usage for replacement later trivial in case you do end up needing a decorator on top of these structures.You don't want these structures to end up spread all over your code base unless you're absolutely certain the requirements of them will never change (hint: requirements of every piece of code you ever write will always change). I guess I should also say, if their only purpose is for the code to be used by client side pieces which rely on the java standard implementations then you're probably safe treating them as primitives.