Doug, Tables, TMOBJS
Hi Das,
Table classes and object classes are very similar. You use them to instantiate objects so that you can use their data and methods.
When you instantiate an object class you use an object variable and this is your interface to the methods that you implement there.
When you instantiate a table class you use a list or a row variable instead. And then that variable is your interface to the methods you put into the table class but also the methods that Omnis already put in. Note: Those are hidden by default and you would need the interface manager to make them visible. I put an enhancement request to make them visible by default.
So here we have the first difference.
The next difference is that table classes can be bound to schema or query classes. When you then define a list or a row from them it also receives the column structure from the connected schema or query class.
With an object class you actually need two variables in your window or remote form. One that represents the object and the other one that receives the data. In case of the table class we have only one variable that represents the data and the functions to load them. So a big plus and less overhead than an object class!
i.e. Do myList.$load()
vers. Do myObj.$load() Returns myList
Also from the OO point of view you put any code that is relevant to the data handling into the table class. Hence you can just ask your list to do this or to load data or to save them.
i.e.
If myRow.$checkData()
Do myRow.$save()
End if
vers.
If myObj.$checkData(myList)
Do myObj.$save(myRow)
End if
What you need to know is that when implementing a method into the table class you need to imagine that you are inside your row or list. That said $cinst is the row or list when you are inside the table class.
For example the method $checkData inside your table class could be like this:
$checkData
If len($cinst.name)=0
;; name must not be empty
Quit method kFalse
Else
Quit method kTrue
End if
Same method in the object class:
$checkData
Parameter pRow
If len(pRow.name)=0
;; name must not be empty
Quit method kFalse
Else
Quit method kTrue
End if
The method within the table class does not need the parameter because it is the data itself.
Check out the new Omnis Academy I made recently: www.omnis.net/academy/online.jsp <www.omnis.net/academy/online.jsp> It deals with table classes and shows how to use them.
Please note: I am not saying that object classes are not useful. I’d rather say that table classes are quite similar but better suited for data handling.
Hope that helps a little.
Best regards,
Andreas
> Am 02.03.2018 um 21:40 schrieb Das Goravani <das@goravani.com>:
>
>
> Dear Doug, my questions are below your typing:
>
>> On Mar 2, 2018, at 6:02 AM, Doug Easterbrook <doug@artsman.com> wrote:
>> We use oldRow extensively in the $update statement to find out what fields have changed for the key purpose of ONLY UPDATING THOSE FIELDS and making the app faster.
>
> HOW do you get the INFORMATION as to WHAT fields changed? I know I have to put old row in the update statement for it to work so I do it faithfully..but I don’t know how to query back what fields changed. Frankly at this point I KNOW what fields changed and I used a SQL UPDATE to list only the one field that needs updating, so I’m with you on only updating the fields that changed for network speed. But how do you get info back from the Omnis $update(old row) combo?
>>
>> Thats a clear example where the table class has benefit and the requirement to provide the old row for comparison purposes gives you the opportunity to optimize the SQL with possibility od significant performance gains.
>
> Aha, mention of Table class with the word BENEFIT. You actually don’t say what the table class does (here) that gives the supposed benefit. WHAT does a Table Class do in this scenario that an Object can’t do. I’m ignorant of the benefits of Table classes and posted just now a discussion provoking post to the list asking what are the benefits of table classes. You have to say in clarity WHY, WHAT, it does, that gives benefit over objects say. Some say tables are unnecessary while you and others say they are great, but I don’t know WHY they are great. Please tell this case’s reasoning. Why? What?
>>
>> it is for that reason, the TMOBJS xcomp thats out there in the wild and free to all has a static method that will provide you with the update statement containing only changed fields. Its useful.
>
> Please explain what you mean by Provide you with the update statement…. Does it use info returned from somehow and build you a SQL command that you paste into place? Does it work on the fly behind the scenes? Do you know where to download it and is it cross platform?
>
>
> _____________________________________________________________
> Manage your list subscriptions at lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en@lists.omnis-dev.com
_____________________________________________________________
Manage your list subscriptions at lists.omnis-dev.com
Start a new message -> mailto:omnisdev-en@lists.omnis-dev.com