#1 2017-04-04 17:57:52

leus
Member
Registered: 2012-09-05
Posts: 79

Migrating big client-server (2 tier) application to mORMot

This has been discussed elsewhere, but this is to check if this migration strategy is possible.

Old and big database applications written in Delphi, written many years ago, usually have the same problems:

- many different dataset scattered across units
- lots of DB aware components depending on an active dataset
- many direct updates in-place using two-way datasets
- lot of direct database oprations (inserts, updated using SQL code)
- stored procedures
- mixed UI and database logic

In most cases, migrating such an application to mORMot is simply not an option. Business reasons vary, but most likely, it implies a total rewrite, and that's simply a big no-no.

The strategy: create a "fake" mORMot server inside the running executable. Make it work alongside the current logic.

In my head, this should be something like this:

- Add a new unit
- Create a "mORMot server" (I still have no idea what this is)
- Add a procedure to update certain existing object (something small, just to test if it works) using some form of direct database access ("update obj where ...")
- Add, during application startup, code to make this "mORMot server" start
- Add (or better yet, replace an existing functionality) code that instantiates the client part (TSQLRestClient using direct access?) and calls the new server method the mORMot way.

This leaves out the most complicated part: existing grids that use TDataSet objects. For this, one could use the (experimental?) TSynRestDataSet by Esteban Martin. The approach would be the same: replace existing datasets with TSynRestDataSet objects, and move the query logic to the server.

Wash, rinse, and repeat, until you have ported all your existing DB code to Restful code.

At this point, all is left is to split the application between the server and client part, and figure a way to migrate existing clients.

What do you guys think of such a plan?

Last edited by leus (2017-04-04 18:02:57)

Offline

#2 2017-04-04 18:19:29

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

Re: Migrating big client-server (2 tier) application to mORMot

TSynRestDataset is not experimental, we will release it in production in the next weeks. The TSynRestDataset born into the need the migration three tier legacy software (RemObjects) to more stable application server, I did rewrite all legacy code for total use of mORMot benefits, and in the middle parallel running partial up to total migration.

Best regards.


Esteban

Offline

#3 2017-04-04 19:00:43

igors233
Member
Registered: 2012-09-10
Posts: 241

Re: Migrating big client-server (2 tier) application to mORMot

The strategy: create a "fake" mORMot server inside the running executable. Make it work alongside the current logic.

In my head, this should be something like this:

- Add a new unit
- Create a "mORMot server" (I still have no idea what this is)

It depends on what you'll do and how. If you only want to have a have a service oriented approach (call function from your client, pass some params and get results) two classes are needed, for example TSQLHttpServer and TSQLRestServerFullMemory. Take a look at docs for more details and in samples dir.

> This leaves out the most complicated part: existing grids that use TDataSet objects. For this, one could use the (experimental?)
> TSynRestDataSet by Esteban Martin. The approach would be the same: replace existing datasets with TSynRestDataSet objects, and move the
> query logic to the server.

Alternative (to classic DBGrids) is to use TDrawGrid and TSQLTableToGrid, it's quite fast and on paar with TDBGrid with features.

Offline

#4 2017-04-04 19:45:21

Junior/RO
Member
Registered: 2011-05-13
Posts: 210

Re: Migrating big client-server (2 tier) application to mORMot

@ab, I think that TSynRestDataSet should be added as a oficial class/component for mORMot. Esteban did a great job here.

Offline

#5 2017-04-04 21:29:11

leus
Member
Registered: 2012-09-05
Posts: 79

Re: Migrating big client-server (2 tier) application to mORMot

EMartin wrote:

TSynRestDataset is not experimental, we will release it in production in the next weeks. The TSynRestDataset born into the need the migration three tier legacy software (RemObjects) to more stable application server, I did rewrite all legacy code for total use of mORMot benefits, and in the middle parallel running partial up to total migration.

Good to know. Hope they get in the main distribution soon. In the meantime, here's a pull request for some small fixes: https://github.com/synopse/mORMot/pull/36


igors233 wrote:

It depends on what you'll do and how. If you only want to have a have a service oriented approach (call function from your client, pass some params and get results) two classes are needed, for example TSQLHttpServer and TSQLRestServerFullMemory. Take a look at docs for more details and in samples dir.

That's part of it, most likely updates and inserts.

igors233 wrote:

Alternative (to classic DBGrids) is to use TDrawGrid and TSQLTableToGrid, it's quite fast and on paar with TDBGrid with features.

Yeah, but I have an application that relies heavily on DevExpress grids and components. Those are really hard to duplicate.

Last edited by leus (2017-04-04 21:42:30)

Offline

Board footer

Powered by FluxBB