2012-06-18

Circular reference and zeroing weak pointers

The memory allocation model of the Delphi interface type uses some kind of Automatic Reference Counting (ARC). In order to avoid memory and resource leaks and potential random errors in the applications (aka the terrible EAccessViolation exception on customer side) when using interface, a SOA framework like mORMot has to offer so-called Weak pointers and Zeroing Weak pointers features.

Note that garbage collector based languages (like Java or C#) do not suffer from this problem, since the circular references are handled by their memory model: objects lifetime are maintained globally by the memory manager. Of course, it will increase memory use, slowdown the process due to additional actions during allocation and assignments (all objects and their references have to be maintained in internal lists), and may slow down the application when garbage collector enters in action. In order to avoid such issues when performance matters, experts tend to pre-allocate and re-use objects: this is one common limitation of this memory model, and why Delphi is still a good candidate (like unmanaged C or C++ - and also Objective C) when it deals with performance and stability.

Continue reading

2012-06-14

Introducing TInterfacedCollection dedicated class

A TInterfacedCollection dedicated class has been defined, properly handling collection item creation on the Server side, with interface-based services: all contract operations shall use a class inheriting from it, instead of the standard TCollection, which was not defined as needed for our high-level needs.

Continue reading

2012-06-13

Retrieve the object instance from an interface

It is pretty useful, in some cases, to retrieve a class instance from a given interface.
You should better use interfaces in your business logic, but having access to the underlying implementation is needed at lower level.

Beginning with Delphi 2010, you are able to use the as operator, e.g. via aObject := aInterface as TObject or aObject  := TObject(aInterface).
This operator use a special hidden interface GUID (ObjCastGUID) to retrieve the object instance, calling an enhanced version of TObject.GetInterface.

But if you want to maintain compatibility with older version of Delphi (as we want for mORMot to work with the beloved Delphi 6 or 7), you'll have to find a way.

Continue reading

2012-05-28

Synopse mORMot Framework 1.16

Our Open Source mORMot framework is now available in revision 1.16.

The main new features are the following:

Thanks to its features, mORMot is now able to provide a stand-alone Domain-Driven Design framework for Delphi.

Quite a long and nice road for a little mORMot, and more to come!

Continue reading

Is marketing the new native?

In a very nice (like always) blog post, trolling comments were dispatched about the "native" concept:

From the technical point of view, both assertions are false.

The article was subtitled: "Say a Lie Often Enough and You’ll Start Believing it Yourself".
At least, it is a trolling subject.

It remembered me about some of my past studies, i.e. five years of university studies in Medieval Theology in Italy and France (yes, I know, this is strange background for a Delphi programmer):

"Stat Roma pristina nomine, nomina nuda tenemus"

Our modern world is not thinking any more, it is sinking into nominalism, whereas IMHO the scientific approach is more compatible with a realistic approach of universals.

Today, marketing is everything.
Is it a necessary evil?

Continue reading

2012-05-25

Domain-Driven design

With a previous article, we introduced the concept of "Domain-Driven design" into our framework presentation.

It's now time to detail a bit more this very nice software architecture design, and how mORMot is able to achieve such an implementation pattern.

Continue reading

2012-05-20

Recursive calls and private objects

In a Stack Overflow question, someone asked about some nested procedure call he found out. That is, a procedure inside another procedure.

He found out this coding style to be messy, which sounds like a reasonable opinion. But his alternative proposal of putting the internal procedure outside the main one, i.e. making it global, is IMHO even worse.

In some case, a private class, or even record or object with methods is an handy and maintainable implementation pattern.

Continue reading

2012-05-03

Custom JSON serialization of records

By default, during interface-based service call, any record parameter or function result will be serialized with our proprietary binary (and optimized layout) - i.e. RecordLoad and RecordSave functions - then encoded in Base-64, to be stored as plain text within the JSON stream.

But custom record JSON serialization can be defined, as with any class - see this article - or dynamic array - see this article.

Continue reading

- page 33 of 52 -