#1 2012-02-29 18:56:35

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

Delphi and interfaces

No, interface(-book) is not another social network, sorry.

In Delphi OOP model, an interface defines a type that comprises abstract virtual methods. The short, easy answer is that an interface is a declaration of functionality without an implementation of that functionality. It defines "what" is available, not "how" it is made available. This is the so called "abstraction" benefit of interfaces (there are another benefits, like orthogonality of interfaces to classes, but we'll see it later).

(...)

Now you may begin to see the point of using interfaces in a client-server framework like ours. Our mORMot is able to use the same interface definition on both client and server side, calling all expected methods on both sides, but having all the implementation logic on the server side. The client application will transmit method calls (using JSON) to the server (using a "fake" implementation class created on the fly by the framework), then the execution will take place on the server (with obvious benefits), and the result will be sent back to the client, as JSON. The same interface can be used on the server side, and in this case, execution will be in-place, so very fast.

By creating a whole bunch of interfaces for implementing the business logic of your project, you will benefit of an open and powerful implementation pattern.

Comments of this article: http://blog.synopse.info/post/2012/02/2 … interfaces.

Offline

Board footer

Powered by FluxBB