#1 2019-11-27 15:23:59

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

[sharing] A advantage of method-based service over the interface-based

Just sharing a thought concluded from real-life projects:

We all know that there are two kinds of services you can define with mORMot:
- Method-based
- Interface-based (the "interface" here is the interface in Delphi/FPC)

A advantage of method-based services over the interface-based ones, is that the **compatibility** to new/old versions of clients.
If you use interface-based services, if you need to add a new parameter - oops! all clients need to be updated **otherwise the call will fail**.
But with method-based services, new versions of clients can submit new parameters while the old clients can keep working, and the server handle it according to what the incoming parameters are.

Just my 2 cents.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2019-11-28 10:56:29

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,672
Website

Re: [sharing] A advantage of method-based service over the interface-based

Note:
If you disable contract checking, and use transmission as JSON object for interface-based services (as you should for a public API), not as the default JSON array (for internal safe calls), then you can add parameters.

See for instance

 TSQLRestClientURI.ServiceDefineSharedAPI() 

and

TSQLRestServer.ServiceDefine(...).ResultAsJSONObjectWithoutResult := true;

Offline

#3 2019-11-28 11:43:21

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: [sharing] A advantage of method-based service over the interface-based

Hey!
I didn't know about that, even after using mORMot for such a long time!
Well done and thanks, ab!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2019-11-28 16:17:51

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: [sharing] A advantage of method-based service over the interface-based

This is new for me too!

Thanks @ab and @edwinsn

Offline

Board footer

Powered by FluxBB