7

With out service contracts:

For example I can extend directly class AccountManagement model. I can override any function.At the same time if core developers add anything in class AccountManagement model in next versions it will reflect my class too.So I dont loss any functionality added by Magento.

With service contracts:

In this scenario also I can extend AccountManagement. I can override any function.At the same time if core developers add anything in class AccountManagement model in next versions it will reflect my class too.So I dont loss any functionality added by Magento.

So what is the difference?

and they are saying we are hiding business logic with service interfaces.

how it possible ? now any one can access AccountManagement class and functions.how they are hiding with interfaces?

and also there is no clarity on preserve data integrity.

I hope i will get better picture on at least some of the points.

1 Answer 1

9

An objective is to define "service contracts" that different people could provide implementations of the interfaces. If clients only use the contracts, they wont be impacted by a different implementation being swapped in.

One thought still be considered is whether the service contract (Api directory specifically) should be in a separate module to highlight this. A module may decide to be tightly bound to a specific implementation and still access classes directly. But if it wants to be more loosely bound, then it would depend on the service contract module only instead.

With regards to protection, with PHP you can access anything. So it is more guidance to developers of what is going to be more stable across releases rather than absolute protection.

The business logic aspect is in part because previously there were cases where business logic was inside the PHTML files. This was not good. We have been moving it down where it belongs - in models etc, not in PHTML files. This makes it easier to replace or adjust HTML without having to copy (and maintain) all the business logic there as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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