#1 2014-11-17 14:42:47

willo
Member
From: Cape Town, South Africa
Registered: 2014-11-15
Posts: 67
Website

Enterprise Application Architecture

Hi guys,

I might be wrong in my approach, but I would like to deal exclusively with interfaces when communicating between client and server. In my sandbox project I have a blog (for example). Let's call it IBlog and IBlog has a method:

  IBlog = interface(IInvokable)
    ['{F4479253-C592-48D3-9658-FFE3C9EE07DE}']
    function getName: string;
    procedure setName(const Value: string);
    
    function getPosts( out Posts : IPosts ) : integer;
  end;

  TBlog = class(TSQLRecordInterfaced, IBlog)
  private
    function getName: string;
    procedure setName(const Value: string);
  public
    function getPosts( out Posts : IPosts ) : integer;
  publsihed
    property Name: string read getName write setName;
  end;

What should IPosts' definition look like?

I've been toying around with IEnumerator, IList and a couple of other friends, but none of these seem to really work well.

Offline

#2 2014-11-17 15:47:55

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

Re: Enterprise Application Architecture

If you use SOA, you should better use DTO.
Records and dynamic arrays are very best candidates for DTO.
Since Delphi 2010, they are directly serialized as JSON.

Otherwise, if you want to return class instances (e.g. any TSQLRecord) you could just use :
- RawJSON, and fill a TSQLTable with the returned content;
- a TObjectList.

For an example of a Blog, including working ORM data model and some MVC commands, see our sample https://github.com/synopse/mORMot/tree/ … C%20Server
You will find here some good practice patterns, to refine your approach.

Offline

Board footer

Powered by FluxBB