Monday, 15 February 2010

java - Why use Interfaces for domain entities? -



java - Why use Interfaces for domain entities? -

what purpose of using interfaces domain entities?

in our project, using interface domain entities. within interface, there getter , setter methods, not domain logic.

is using interface entities useful? practice?

thanks.

there plenty of reasons why it's thought sometimes depends on scope of project.

first of all: statement "...not domain logic." doesn't create sense, there can't logic in interface, interfaces can't have logic, method signatures.

the main reason why done back upwards multiple implementations of domain objects different uses.

reasons why might want code domain objects interfaces:

serialization - want create serializable versions of domain objects don't want mix code code utilize core app. example, might have implementation of person object utilize serialize json webapp.

shared api - might want distribute public api version of code has different implementations of objects, or might want create interfaces available grouping (or client, or vendor)

support legacy implementation - maybe have info in old database need build connector involves different implementation of domain objects pull info out.

testing - having interfaces core classes makes unit testing lot easier since can stub out methods don't need testing.

java interface entity

No comments:

Post a Comment