Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share model between client and server

Due to our domain model and proccess we are looking at sharing model between client and server. Our client is really thick client. Is there any information about such architecture, pros and cons?

like image 346
Backs Avatar asked Dec 11 '13 09:12

Backs


1 Answers

Theoretically if your Domain layer is totally decoupled (from persistence, presentation, infrastructure, etc.) it can easily be reused as a library in different places.

However, as Adrian points out, this raises practical issues :

  • Security : distributing your domain especially in client applications can be risky. One way around that is to obfuscate your binaries if the client is a desktop app.

  • Platform mismatch : you might not be able to use the same technology/language on client and server. This will result in a translation of your domain, basically doubling the initial amount of work, maintenance cost and bug proneness.

  • Versioning : even if the same library is reused, its versions on the client and server must probably be kept in sync to prevent incompatibilities.

Besides, except if you're developing a web version that is an exact clone of a desktop version, I feel that the domain reuse will be partial at best. In the case of a single client/server application, I'm curious to know why you would use the same domain on both tiers... usually what you have on the client side is data structures that might look a bit like the domain entities, but tweaked for the UI, and with no behavior. In that case, reusing the whole domain layer on the client side would mean dragging along a bulky object graph that maybe partly does what you need but also a ton of other unneeded stuff.

Maybe what you need instead is the concept of Bounded Context from Domain Driven Design - same class names but slightly different classes in Client context and Server context.

like image 67
guillaume31 Avatar answered Sep 21 '22 14:09

guillaume31