On Apr 9, 2018, at 10:06 AM, Tim Nevels via 4D_Tech <4d_tech@lists.4d.com> wrote:
> What is ORDA? It is not a “a historical sociopolitical and military structure > of Mongol Eurasia”. This is a new term that 4D has created. It stands for > Object Relational Database Access. It might be a new term 4D created, but it will basically be a stripped-down ORM (Object-Relational Model) to start with. It is stripped-down because it only includes a pseudo-object that we can’t yet define except for the attributes, and a query language. The concept of an ORM is not new, and actual implementations date to the early 90s (the Enterprise Object Framework (EOF) from Next is the first one I’m aware of, although I’m not sure how the query language worked, since I’ve never used it beyond a WebObjects class in the late 90s. > Many, many changes to the 4D language are coming. I sat at a table with > Laurent and some other 4D developers at lunch one day and Laurent said the > new 4D language will be “JavaScript inspired”. He intends to add features to > the 4D language so that it will be even better than JavaScript! Inheritance, > error handling, custom data classes and the list goes on and on. The days of > the 4D language not getting updated are over. The changes are just getting > started. Hopefully someday we can get the concept of closures and no longer need the various EXECUTE permutations to run global methods in various contexts. > One example of a change in the 4D language is the “For each” loop control > structure. Super useful and needed when dealing with objects and containers. Yes, using for/in (for/each? can’t remember) will be nice, when we have Entities and maybe even custom classes we can define. It would have been nice to have a variation that iterates through the keys/values when C_OBJECT was added to the language. > So you want an example of ORDA and changes to the 4D language? Here’s one > form JPR’s advanced class. (Hope I am not doing copywriter infringement > here.) > > You have a table called “Employee”. Just one table. It has a “managerID” > field and has a relation back to the “ID” field of the same table. (Yeah, > that’s not possible in the current version of 4D, but it is in v17.) The name > of the relation is “manager”. Find all Employees working for a manager whose > “firstname” is “Laurel”. Here is how you would do it now: > > QUERY([Employee];[Employee]firstname="Laurel") // First Query > ARRAY LONGINT($arIDs;0) > SELECTION TO ARRAY([Employee]ID;$arIDs) > QUERY WITH ARRAY([Employee]managerID;$arIDs) > > That gives you a selection of [Employee] records. Here is how you do it via > ORDA in v17: > > $entSel:=ds.Employee.query("manager.firstname = ‘Laurel’ “) > … > And it can be recursive. Say you want to find the managers of the managers > whose name is “Laurel”. You do it like this: > > $entSel:=ds.Employee.query("manager.manager.firstname = ‘Laurel’ “) Ruby on Rails has had similar syntax since the 2005 timeframe (part of the ORM), but it’s nice to see these concepts finally making their way to 4D. It will definitely reduce the pointless amount of 4D code you have to write to do almost anything. Considering that query language like this has been implemented in other ORMs for decades, primarily on top of SQL databases, it’s likely that 4D is actually using the 4D SQL engine underneath the new query language. The SQL implementation already queries the database without changing the (one) current selection, and in your example above, $entSel is not a “current selection” (they referred to having as many “selections” as you want), it is a collection of entity objects. In fact, aside from the syntax, someone with Cannon Smith’s tenacity could have implemented something fairly close, probably in less time than he spent implementing his MVC 4D framework for forms. It just would have had to look something like $conditions:=ORM_Set_Conditions(”fname”;”Laurel”;”lname”;”Hardy”) ORM_Query(“Employee”;->$empArr;”manager.firstname = :fname AND manager.lastname = :lname”;$conditions) > 4D Summit 2018 would not be complete without mentioning 4D for iOS. They must be including the 4D Server connectivity framework in the Xcode project. That is the most interesting piece, I could see using the component to generate a starter app which could then be modified to do do whatever else is desired. This is not to say that I’m not looking forward to having this functionality in 4D. But really 4D should have had an ORM with a sensible query language a decade ago, like multiple popular open source frameworks. Cannon should not have had to spend months or years on his MVC framework; 4D should have had the concept of a real form controller years ago, with ways for us to define custom events for it to handle, timers that make sense, etc. The new text format for a structure will be nice, it will finally be possible to integrate with GIT or SVN without having to jump through major hoops, but again, this is where every other development framework has been since approximately forever. It’s nice to finally see progress, but it’s sad that 25 years ago, 4D was 5 years ahead of most other options, and now it is 10-15 years behind. Jim Crate ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************