When in Rome, do as the Romans do - Part III

In Delphi, properties can be backed by simple fields, but they can also have getter and setter functions that can be vital to the proper functioning of a class. They can contain additional initialization code, protect the consistency of the object's data, prevent invalid input...

Photo: Gary Todd from Xinzheng, China, PDM-owner, via Wikimedia Commons, https://commons.wikimedia.org/wiki/File:Colosseum_(48412957912).jpg

As you might guess, field-based serialization does not call the appropriate getters and setters, and can cause runtime malfunctions. On the other hand, property-based serialization calls getters and setters if any exist.

This is another thing to consider when using REST.Json, which uses field serialization instead of property serialization.


Popular posts from this blog

Coming in Delphi 12: Disabled Floating-Point Exceptions

Assigning result to a function from asynchronous code

Beware of loops and tasks