My Top 10 Aurelius Features - #3 Inheritance

Tuesday, February 21, 2017

How to talk about object-oriented programming and not consider inheritance? In my opinion is a basic "feature" of OOP. And how to talk about an ORM without supporting inheritance? I consider it so important that the simply fact that Aurelius supports it makes it my #3 of My Top 10 Aurelius Features.

It's really nice to be able to model classes and build a class hierarchy, reference classes in that hierarchy from other properties, have a true model that is not just a bunch of plain classes that map properties to database columns. Inheritance support allows you to really think in an OOP way when using an ORM.

TMS Aurelius supports two ways of persisting objects in a class hierarchy in the database:

Joined-tables strategy
Where data from each class is saved in a different database. This is the more normalized way.

Single-table strategy
Where data from all classes are saved in a single table. This is the simplest and often offers better performance.

Regardless of your choice, the facts is that Aurelius allows you to do so! Watch the video above to see how class inheritance works with TMS Aurelius, and if you want to get notified about upcoming videos, subscribe to our YouTube channel!

Wagner R. Landgraf


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

My Top 10 Aurelius Features - #4 Aurelius Dataset

Thursday, February 09, 2017

I consider Aurelius Dataset (TAureliusDataset) a hidden gem of TMS Aurelius. Well, not exactly "hidden" because it's a significant part of it to deserve its own chapter in the Aurelius documentation, but in the sense that it's different from the normal ORM "core" which is update, insert, delete, select, query, etc.. And for that it's #4 of My Top 10 Aurelius Features.

The first misunderstanding about the TAureliusDataset is confusing its usage with the regular way we use Delphi datasets. I've been in discussions in forums with people that were blaming the usage of dataset, because it's not "good practice", because logic should be in the controller/model, etc., etc..

The point is Aurelius Dataset is for data binding. It's not about retrieving data. You will retrieve data the same way with or without the dataset. Your logic, controller and model will still be isolated. But when it comes to show or edit data of an entity in a visual form, you don't have to manually do things like this:
edCustomerName.Text := Customer.Name;
edCustomerCity.Text := Customer.City;
or even worse, to populate a grid or list (pseudo-code):
for Customer in Customers do
  CurrentRow := Grid.AddRow;
  Grid.Columns[0, CurrentRow] := Customer.Name;
  Grid.Columns[1, CurrentRow] := Customer.City;
that's tiresome, repetitive and not necessary with Aurelius Dataset. You just set the "data" of the dataset, which are your objects:
and you bind the dataset to data ware controls! Or to regular controls use live bindings. Or provide the dataset to some report tool.

The coolest thing about the Aurelius Dataset is that its minor features and high integration with Aurelius. It's not just a generic binder between Delphi objects and controls. But it handles smoothly a lot of specific Aurelius features like:

Nullable types
Associations and its sub-properties
Master-Detail (many-valued association as nested datasets)
Enumerated types

and provide the regular dataset mechanisms but adapted to the object-oriented approach, like:

Lookup fields
Calculated fields
Design-time support

And finally, it handles paging and fetching smoothly as well. You can have a criteria that is retrieved page by page on demand, avoiding all objects to be retrieved at once, and at the same time avoiding a cursor to be open to the database!

Watch the video above to see Aurelius Dataset in action, and if you want to get notified about upcoming videos, subscribe to our YouTube channel!

Wagner R. Landgraf


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

My Top 10 Aurelius Features - #5 LINQ Expressions and Paging

Monday, January 30, 2017

Most examples and quick-start tutorials about ORM frameworks explain how to insert, update and retrieve single entities in the database. But not many of them go further and show how to perform a query in the database. Maybe because that's something that the developer will only need after many data is inserted, and it's something that is only heavily needed when the application development is at a more advanced stage. However, it's a very important feature, and that's why "LINQ Expressions and Paging" is my #5 feature of My Top 10 Aurelius Features.

The reason for that is because you can really query your entities in a object-oriented way. It's not some SQL-like string you build, or SQL WHERE statement that you simply inject. It's really about querying object properties, comparing their values in Pascal (not in database), and using Pascal syntax to build the queries. Take a look at this example:

  MyCustomers := Manager.Find<TCustomer>
         (Linq['Birthday'] > EncodeDate(1981, 10, 10))
         and (Linq['Birthday'] < EncodeDate(1986, 2, 2))
      or ((Linq['Sex'] = tsFemale) or Linq['Sex'].IsNull)
      or Linq['Name'].Contains('Walker')
      or Linq['Status']._In([TCustomerStatus.Active, TCustomerStatus.Prospect)
That's an example of filtering by Birthday property using logical operators "and", "or", how you can use parenthesis and have Delphi give you compile errors if expression is wrongly constructed. And of course you have extra expressions like "Contains", "In", etc.. All in Pascal.

Finally, a small feature of LINQ filtering that I enjoy a lot: paging. It's very simple to use and very handy:
  MyCustomers := Manager.Find<TCustomer>
The code above in theory should bring all customers, but will only bring 10 customers, skipping the first 50 in the specified order. This is great for bringing a long list but in parts, page by page. And of course you can use it with any criteria you specify, like the complex one illustrated above in this post.

To see in details how LINQ expressions and paging works, watch the video above, and if you want to get notified about upcoming videos, subscribe to our YouTube channel!

Wagner R. Landgraf


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

TMS Aurelius and MVVM Design: an example

Tuesday, January 24, 2017

John Kouraklis has posted a 2-part article in his blog about using TMS Aurelius and MVVM. From the article: "Model-View-ViewModel (MVVM) design pattern allows developers to write software in a way that separates applications to layers that serve the business logic, the presentation logic and the elements of the user interface."

You can follow the links below to read the article:

He's also published the "MVVM in Delphi" book, you can purchase it from Amazon. More info about the book here.

Wagner R. Landgraf


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

Previous  |  Next  |  Index