Should I use Enums from JAXB objects in my production code?

We have this project where JAXB objects are decoupled from production code. We created an object inside production code (which was based on JAXB objects). These JAXB objects also generate enums automatically. What should I do? Should I still use these JAXB enums or create a separate enum inside production code? Would it be too expensive?

+3


source to share


1 answer


Possible options:

  • Implement a separate entity model, use JAXB-based classes only as DTOs, implement entities → DTO converters.
  • Use schema-derived classes directly as an entity model.

The first option is more expensive, but you have a clearer separation between business logic and facade tiers.

The second option is cheaper, but you are completely driven by the scheme.



Using schema-inferred transitions (or other schema-based classes) in business logic puts you in the second option. As mentioned, it's fast and cheap and works reasonably well - as long as your business logic is completely schema driven.

But this fails if your business entities have meaning of their own. Consider the following questions:

  • What happens if the schema is changed?
  • What if you need to maintain multiple schema versions in parallel?
  • What if you need to support other channel formats besides XML?
  • What if you need to add functionality to your business objects that you cannot (easily) auto-generate?

A clean separation between business units / data types and DTOs helps a lot. The changes / requirements described above will only affect one level, not the business logic or below.

0


source







All Articles