Opinions on using units from a DataSnap REST Server for the client project

747 views Asked by At

I'm developing a prototype DataSnap REST server with a FireMonkey desktop client, and was wondering whether using the units that encapsulate the data models in the server for the client was good practice or not.

That is, I have a number of units for the server project that represent the data model objects and properties, and I have REST server methods that either take these objects as parameters or return them as results.

Since I already have these units, I just added them to the client project where needed, however the DataSnap REST server application will also be used from a C# desktop client (and possibly a HTML 5 web app), which won't be able to use the .PAS units I have and would need their own representations of the objects.

Would it be better for me not to use the server project units, in order to ensure that I'm not including anything that a non-DataSnap client would know about, or go ahead as I have and write the C#/Java models manually, or is there an automated way to generate those models, similar to the way Visual Studio generates class models from WSDL?

1

There are 1 answers

1
Erwin On BEST ANSWER

With DataSnap Mobile Connectors it is possible to generate in automated way the DataSnap client classes in different languages like C# or Java for Android for example.

For HTML5 client application a JavaScript proxy class can also be generated from the DataSnap REST Application wizard.

In FireMonkey client application you have advantage it is possible to share units with server project. With the generated proxy classes in other languages it remains to be seen if business logic is also included. It is a good starting point anyway.