First of all, I must say that I am thoroughly impressed with Ember JS and definitely plan to use it. Ember Data is very impressive as well, but I do have some issues in my mind that I need to iron out before using Ember Data.
I come from a java background and have transitioned from Java EJB to Java, Spring, Hibernate to Grails. The typical MVC Architecture that I’m used to is:
- Controller Layer – Grails Controller
- Service Layer – Grails Service
- DAO and Model Layer – GORM mapped to RDBMS
This is an architecture that:
- Keeps my Business Logic secure on the Server Side
- Allows me to expose my Business Logic as web Services to other UI Apps
- allows me to rewrite my UI or my back end without one impacting the other.
- Keeps my UI JSON Model separate from my Back End Domain Model so that my views are not tied to my Domain Model and don’t have to conform to it.
I’m a bit confused about if and if so where Ember Data could fit in for me. Looking at Ember Data, it appears to me that:
- It is definitely an amazingly written framework, but a bit unconventional for me in terms of architecture.
- It seems that the Ember Data Model Objects seem to be mapped directly to my Domain Model. There is no concept of a UI Model. Hence the UI Model is tightly coupled to the Domain Model.
- It appears that Ember Data IS my business logic layer and it is calling persistence operations. The back end basically consists of domain objects related to each other accessible over REST.
I’m a bit uneasy with this architecture because:
The application’s domain model and business logic is on the client side controlled by a client side transaction layer.
a. The client side transaction layer is not really in-sync with the back end transaction layer in cases of rollbacks.
b. I see this as a big security risk in terms of exposing your Data Model and Business logic in the client side.
If you have a back end sequence like so that needs to all take place in 1 transaction:
a. Create Sale --> Create A Sale Record
b. Create Line Item records for each of the Sale Line Items
c. associate each Line Item to the Product
d. Associate each Line Item to the Sale Record
e. then for each Product for each Line Item, decrease the inventory quantity by the line item quantity.
In this case, I was wondering if someone could help me understand:
- Is it possible for me to use Ember Data in my case and still keep my Services Oriented Architecture?
- Am I missing something or not understanding something correctly?
- If the answer to 1 above is yes then what is the best way for me to use Ember Data?
I really like Ember and would like to use Ember Data. I would really appreciate if somebody could help me out with my questions above.