Tips: ORDA Data Model Classes

By now you’re aware of the availability of ORDA classes. In this blog post, you’ll learn a few handy tips to get the most out of them!

UsE strongly typed variables

You can strongly type your ORDA variables and take advantage of autocompletion thanks to the var keyword.

In the example below, $dataclass is typed as a dataclass class (cs.Students) and initialized with the Students dataclass object (ds.Students). Autocompletion automatically suggests:

  • all of the functions defined at the dataclass level (new(), query(), etc.)
  • all of the functions that you’ve implemented yourself in cs.Students (in this example: search())

 

Call functions dynamically

You’ve most likely used the [ ] notation to access the attributes of an object (e.g., $myObject[“propertyName”]). This is also possible with functions!

Here’s an example (psst …. don’t forget the ( ) at the end!):

There is a getDescription() function defined on the datastore class.

Class extends DataStoreImplementation
Function getDescription
 C_TEXT($0)
 $0:="Learning system covering "+String(This.Students.all().length)+" students"

It can be dynamically called like this:
C_TEXT($what;$functionName;$1)
$functionName:=$1
// $functionName can be "getDescription"
$what:=ds[$functionName]()

Avatar
• Product Owner • Marie-Sophie Landrieu-Yvert has joined the 4D Product team as a Product Owner in 2017. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Marie-Sophie graduated from the ESIGELEC Engineering School and began her career as an engineer at IBM in 1995. She participated on various projects (maintenance or build projects) and worked as a Cobol developer. Then she worked as an UML designer and Java developer. Lately her main roles were analyzing and writing functional requirements, coordinate business and development teams.