In an oriented-services enterprise application, isn't it an antipattern to mix Service APIs (containing interface that external users depends on) with Model objects (entities, custom exceptions objects etc...) ?

According to me, Services should only depends on Model layer but never mixed with it.

In fact, my colleague told me that it doesn't make sense to separate it since client need both. (model and service interfaces)

But I notice that everytime a client asks for some changes, like adding a new method in some interface (means a new service), Model layer has to be also delivered...

Thus, client who has not interested by this "addition" is constrained to be concerned by this update of Model... and in a large enterprise application, this kind of delivery is known to be very risked...

What is the best practice ? Separate services(only interfaces so) and model objects or mix it ?


It depends on whether client is using exactly the same domain model as the server/service. Typically it doesn't, so they should be kept separate IMO.

  • In my case, they are shared with all clients. My reason to separate it is the following : Client A asks for a new need. This need does not impact Model objects since it used existing ones. So, no need for others clients to update the "shared model" for a functionnality they don't expect and eventually get existing functionnalities broken by some new ignored impacts/bugs (very frequent in large enterprise applications) – Mik378 Mar 23 '12 at 15:40

It sounds like you're referring to data models, not business models, and to me data models are just dumb data objects. Their sole purpose in life is to hold data, and they don't perform any business logic or functionality. There shouldn't be any problem with keeping them completely separate from the rest of the application code.

So typically my data models reside in their own library, which the business layers can reference, while business models will usually be part of the business layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.