My Top 10 Aurelius Features - #10 Automapping

Monday, December 05, 2016

This is the #10 feature of My Top 10 Aurelius Features. Follow the link for the full list!

Using the automapping feature is easy: you just need to add the [Automapping] attribute to your class:
type
  [Entity, Automapping]
  TCustomer = class
  private
    FId: Integer;
    FName: string;
  public
    property Id: Integer read FId write FId;
    property Name: string read FName write Name;
  end;

and it will automatically map the class to the database using some conventions. This prevents you from having to manually use the mapping attributes like Column, Table, Id, etc., to tell Aurelius exactly how the database schema will be.

If you already have an existing database, this is not very useful since the convention used by it will probably not match your existing database. But when you do the code-first approach (my favorite) - where you start your application creating the classes, not the tables - this is very handy.

Besides the obvious fact that Automapping speeds up the development process (prototyping is really fast with it), what I really like about Automapping is how it makes you forget about the database and think only about classes: you just don’t remember you have a table or a column somewhere in the database - let Aurelius chooses whatever it needs for the underlying database, and focus on your code.

Another interesting thing is that it’s not an all-or-nothing feature: you can have use the Automapping attribute but still override it with specific mapping attributes - so you get the best of both worlds: convention with flexibility:
type
  [Entity, Automapping]
  TCustomer = class
  private
    FId: Integer;
    [Column(‘CUSTOMER_NAME’, [TColumnProp.Required], 120)]
    FName: string;
  public
    property Id: Integer read FId write FId;
    property Name: string read FName write Name;
  end;

And to conclude, here is a small video (~4 min) showing Automapping usage:



Wagner R. Landgraf


Bookmarks: 

This blog post has not received any comments yet. Add a comment.



My Top 10 Aurelius Features - Introduction

After the release of TMS Aurelius Free Edition, the free version of our ORM framework, I’ve been thinking to do some blog posts about some key TMS Aurelius features. However I spent some time deciding what features to show: would they be in chronological order? Separated by categories? In order of “importance” - and what would be the criteria of “importance”?

Well, finally, as you can tell from the title of this post, I decided to do that in a “top 10 list” format - who knows, maybe this series will appear at Buzzfeed… But most important of all: this is my personal list of favorite features. So no objective criteria here - just some features I consider cool, features that I have “respect” for because were hard to implement or simply features that I use a lot.

So let’s go for the list. Starting with #10, I will keep adding new blog posts over time until I reach feature #1. Hope you enjoy it:

#10 - Automapping

Wagner R. Landgraf


Bookmarks: 

This blog post has not received any comments yet. Add a comment.



TMS online videos presented at CodeRage XI

Tuesday, November 22, 2016

During CodeRage XI, the online event from Embarcadero, Bruno Fierens (founder TMS software and Embarcadero MVP), Wagner Landgraf (TMS Business product manager) & Roman Yankovsky (TMS FixInsight product manager and Embarcadero MVP) brought sessions covering our latest technologies FNC, myCloudData, Aurelius, FixInsight developed at TMS software.

If you missed one of these sessions, you can now watch them via our Youtube channel.

New video's published at tmssoftwareTV:
Cross Framework UI Controls - by Bruno Fierens: This session explains the differences between the VCL and FMX framework that are relevant for custom user interface control development. Given these differences, an abstraction layer, FNC is presented that enables creating custom user interface controls starting from a single source code base that can be used for both VCL, FMX (and LCL) applications. In the last part of the session, several complex FNC UI controls that are in the TMS FNC UI Pack product are demonstrated that can be used in VCL, FMX, LCL applications and target this way Windows, iOS, Android, macOS and Linux.



Metadata assisted automatic DB form generation for cloud data - by Bruno Fierens: The myCloudData.net service offers easy to use structured cloud data storage. The foundation of the service is a REST API. For our Delphi users, we added several components to consume this service with an absolute minimum amount of effort. The TAdvmyCloudData component enables using object oriented programming techniques for using the myCloudData.net service. With TAdvmyCloudDataDataSet and TAdvmyCloudDataDataConnection, controls can be bound directly to the data in the cloud, be it via DB-aware controls or livebindings. For the next level of automation: bound DB forms auto generated with the help of rich metadata, two components are available, TAdvmyCloudDataFormPanel and TAdvmyCloudDataFormBox.



TMS Aurelius Free Edition, an overview - by Wagner Landgraf: An overview of the well-regarded Aurelius ORM framework for Delphi, which now has a free edition for commercial use, available for Delphi 10.1 Berlin.



FixInsight: Finding Bugs with Static Code Analysis - by Roman Yankovsky: Roman Yankovsky shows you how to use FixInsight's static code analysis in Delphi to find bugs in your code before your customers do. Roman Yankovsky is an Embarcadero MVP and the author of FixInsight static analysis tool for Delphi.



Nancy Lescouhier


Bookmarks: 

This blog post has not received any comments yet. Add a comment.



TEncryptedIniFile: easy to use class for handling app settings with encryption

Thursday, November 10, 2016

What's wrong with the KIS principle to store application settings in an INI file? The risk that someone is tampering with the INI file is an often heard reason for not using them. Not being able to store private or secret information another one.
Both issues are solved with the introduced TEncryptedIniFile class. It descends from TMemIniFile and is as such a drop-in replacement and will deal only in app memory with decrypted data. In the file itself, the data is at all times encrypted. To build TEncryptedIniFile, we internally use AES 256bit encryption offered by the TAESEncryption class in TMS Cryptography Pack.

The code to use TEncryptedIniFile becomes something like:
const
  aeskey = 'anijd54dee1c3e87e1de1d6e4d4e1de3';
var
  mi: TEncryptedIniFile;
begin
  try
    mi := TEncryptedIniFile.Create('.settings.cfg', aeskey);
    try
      FTPUserNameEdit.Text := mi.ReadString('FTP','USER','');
      FTPPasswordNameEdit.Text := mi.ReadString('FTP','PWD','');
      FTPPortSpin.Value := mi.ReadInteger('FTP','PORT',21);
      mi.WriteDateTime('SETTINGS','LASTUSE',Now);
      mi.UpdateFile;
   finally
      mi.Free;
   end;
  except
    ShowMessage('Error in encrypted file. Someone tampered with the file?');
  end;
end;
Of course, the weakness now is that the AES key is in the EXE file and as such, it won't stop seasoned hackers to extract it from the EXE and use it directly to decrypt/encrypt the settings file and tamper with it this way. Extra steps could be taken to use an AES key that is a combination of a unique machine ID and a part that is encrypted with a Ed25519 generated public key and decrypt the encrypted part of the AES key on the fly in the app with the Ed25519 private key and then use it in combination with the machine ID to encrypt/decrypt the INI file. That should make the effort to hack the settings file already a lot more difficult.

To start using this TEncryptedIniFile you can get TMS Cryptography Pack and you can download the TEncryptedIniFile class source here.


Bruno Fierens


Bookmarks: 

This blog post has not received any comments yet. Add a comment.



Introducing Sergey Gladkiy and TMS Analytics & Physics Pack

Monday, November 07, 2016

It's always a privilege and honour to be able to work with very smart people who are not only expert in Delphi but also expert in a specific domain. Earlier this year, Bernard Roussely and Marion Candau joined tmssoftware.com and focus so far on advanced cryptography algorithms with the highest security levels in TMS Cryptography Pack. More tools that will use this underlying strong technology are already in the pipeline. Around the same time, also Roman Yankovsky joined tmssoftware.com and the static code analysis tool TMS FixInsight is the result. With TMS FixInsight, you can bring your Delphi code to a higher quality & safer level with numerous code hints and suggestions it gives.
Today, I'm proud to announce Sergey Gladkiy joins the TMS team for working on products with a strong mathematical background. The first result is the TMS Analytics & Physics Pack. This pack offers a set of (non-visual) platform independent classes to work with mathematical expressions and units of measurements. In TMS Analytics & Physics Pack, you can do evaluation of complex multiparameter mathematical expressions, including expressions with complex numbers. You can do physical measurement conversions of all kinds. But perhaps the most amazing part is symbolic derivative calculations. In this respect, TMS Analytics & Physics Pack brings a math wizard in the form of classes that can be used in VCL and FMX apps. You can discover the power of this library via the included demo but I wanted to share some examples of symbolic derivative calculations that will boggle your mind:

Task: calculate the derivative function of:
1/(x-1)+(2*x-1)/(x+1)^2

Result:
(-(1)/(x-1)^2)+(2*(x+1)^2-(2*(x+1)^(2-1))*(2*x-1))/((x+1)^2)^2

The code to achieve this is as simple as:
var
   f,df: string;

   f := '1/(x-1)+(2*x-1)/(x+1)^2';

   try
      if Translator.CheckSyntax(f) then
      begin
        df:=Translator.Derivative(f,'x');
        ShowMessage('Derivative function :' + df);
      end;
   except
      ShowMessage('Error');
   end;
Let's take another example with some trigonometric mathematical functions:

Task: calculate the derivative function of:
(sin(x)+cos(x))/x

Result:
((cos(x)+(-sin(x)))*x-(sin(x)+cos(x)))/x^2

The resulting derivative expression can then be evaluated, for example against x=2:
var
   df: string;
   v: TValue;

   df := '((cos(x)+(-sin(x)))*x-(sin(x)+cos(x)))/x^2';

   try
      Translater.Add('x', 2.0); 
      if Translator.CheckSyntax(df) then
      begin
        v :=Translator.Calculate(df);
        ShowMessage('Result :' + s:=TUtilities.SafeToString(v));
      end;
   except
      ShowMessage('Error');
   end;
The result of this calculation is: -0,786009779256047.

I kindly invite you to explore our new TMS Analytics & Physics Pack. A fully functional trial version is available and the registered versions comes with full source code. We're eager to learn in what kind of exciting and cool applications these powerful classes will find a place!

Bruno Fierens


Bookmarks: 

This blog post has received 6 comments. Add a comment.




Previous  |  Next  |  Index