Product

4D initiates a new variable type: Collection

4D v16 R4 introduces a new type of variable called Collection. What are these variables intended for? Like Objects or BLOBs, collections can be used to hold almost any kind of variable types like texts, numerics, booleans, objects and even other collections. The good thing is that, all these variables types previously mentioned can be mixed inside the same collection, where arrays must always contain the same type of elements!

Product

Validate your JSON object

We use more and more the JSON format. For example, to save settings in a file, to store software configuration, or to exchange client-data on the web with other servers.

How can you validate that the received data is in the expected format? How can you validate that all the necessary information is actually present? How can you do this validation without writing a tiresome method for each type of JSON format?

Simply by writing a JSON schema and use the JSON Validate new command!

Product Discover how object notation can simplify your developer's life!

Discover how object notation can simplify your developer’s life!

With the object notation, available as a preview in 4D v16 R4, your code is simpler to write, easier to read and more natural to think. That is true. But did you really see the full potential of the object notation?

Before 4D v16 R4, when you wanted to create a detail form to enter contact information from an object field, you had no choice but to write an expression like OB GET ([CONTACT]Info; “City”) in the variable data source. You could retrieve the attribute value, but it was not possible to change it. Moreover, you had to write a loadRecord method with the OB GET command for each attribute and a saveRecord method with the OB SET command for each attribute.

What does object notation change in this scenario? From 4D v16 R4, you just write [CONTACT]Info.City in the variable data source! This variable is available in Read/Write mode. OB GET and OB SET commands are no longer necessary. That’s it! Now you see the full potential.

Product

Another way of coding: Object notation

Objects are great, everyone says so. Beside their wonderful flexibility, they are unbelievably fast. You can search through millions of records in just a fraction of a second. 4D v16 even allows to order by object attributes, and to do calculations such as Sum or Average.

With 4D v16 R4, the 4D language has been drastically enhanced to make the usage of objects much more comfortable – with the support of the object notation. Fast, flexible, efficient and now elegant!

Product

Get ready for Object Notation

You are looking forward to start coding with Object Notation? For sure, Object Notation will make your life easier as a developer. But before activating it in your existing application, you should make sure that your code is ready.

The new Object Notation syntax introduces some restraints as 4D language now considers the three following characters as reserved symbols: “ . ”, “ [ ” and “ ] ” (i.e. dot, opening and closing brackets).

As a consequence, once you have activated the Object Notation in your database, it is no longer allowed to use these symbols in variable names, method names, table names, or field names. And of course it is the same for your existing code!

So it is important to check that your application does not contain these symbols before activating this feature. But don’t worry the MSC can do it for you!

Product

New object: an easy way to initialize an object

Discover New object, the new command of 4D to initialize an object. This command allows you to either create an empty object or create it with some initial properties and values. OB SET is now becoming unnecessary in several situations, New object is enough.

New object also allows to re-initialize an temporary object in a loop or simply directly pass an object as a parameter to a 4D command requesting an object as parameter, as Get database measures or GRAPH commands for instance.

This new command changes your way to write 4D code in many situations. New object creates an object and returns a reference to it. It allows more flexibility in your code. This command is the first of a series of new features related to objects … Stay tuned !

Product 4D Database: Search in array attribute

Search by linking array attribute query arguments

Object fields, introduced with 4D v15, allows to store and index unstructured data. This could be a common set of data, like first name, last name, birthday. It could be different data in each record, such as a shop that will need different attributes for shoes (size, color), computers (CPU, memory), printers (color, ink), a list of values or all in any combination.

Here is a real User Story from a 4D customer :

My badge application manages the access rights for each person to a building and for a time slot. This information is stored in a database as an array of objects ( e.g.: {access right, building, time slot} ). I want to be able to look for people who have access to a building during a time slot.”

4D provides several ways to query for data, using index and so extremely fast.

Product 4D Database: Sort records by object attribute

Sort records by object attribute

At each 4D release, object fields become more and more powerful.

A new 4D command for sorting your record selections according to one or more attributes is now available with 4D v16 R2. The new command ORDER BY ATTRIBUTE works the same as the command ORDER BY; you just have to pass an attribute path by which you want to order your selection – easy!

Product

Go further with Object fields

Object fields introduced with v15 allows unstructured data bases, similar to schemaless database (NoSQL). 4D v16 goes a big step further. Get a dynamic structure for unstructured data… Confused?

Imagine you use an object field to allow your customers to store custom data, where they can create their own fields. This works well and is one of the most interesting reasons for using an object field. The problem is, how to allow your customer to query this unstructured data? You don’t know which ‘fields’ they used, you cannot build a query editor on top or offer a drop down with used values.