How to avoid duplicating methods

Max Hattenback maxh at carrubba.com
Fri Jan 6 15:41:43 UTC 2023


Hello Martin,

I think you would want to create an "Employee Object" that holds the data and all common operations on that data, both your windows would load the data from the object into whatever display / edit fields are needed and your "save method" inside each window would simply be "Do EmployeeObject.$save() returns flag".
________________________________
From: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> on behalf of Martin Obongita via omnisdev-en <omnisdev-en at lists.omnis-dev.com>
Sent: Friday, January 6, 2023 10:26 AM
To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
Cc: Martin Obongita <martin.obongita at yahoo.com>
Subject: Re: How to avoid duplicating methods

Hi Andy,
The reason my initial query was not understood was because I mentioned subwindows.
So I set the subwindows aside.
I have 2 windows that are saving an employee record.
Having the "save" method in both windows is duplicate method.
Just like we have inheritance method in a subwindow, is there a way to inherit methods from another window which is not a subwindow?
Or any other way I can work around this duplicity of code?

Martin Obongita.


    On Friday, January 6, 2023 at 06:15:49 PM GMT+3, TBS <andyh at totallybrilliant.com> wrote:

 Martin

With apologies but the way you have described it - from your first window you are calling the parent method to save no ?

So the second window would simply do exactly the same as the first window.....

Apologies if I am not understanding the way you are describing it but the replies so far are all based upon that I think, but you say thats not it ????

Andy Hilton
Totally Brilliant Software Inc
Phone (US) : (863) 409 4870
Phone (UK) : 0207 193 8582
Web : www.totallybrilliant.com<http://www.totallybrilliant.com>
Helpdesk : https://totallybrilliantsoftware.supportsystem.com/
Email : andyh at totallybrilliant.com
On Jan 6, 2023 at 10:09 AM -0500, Martin Obongita via omnisdev-en <omnisdev-en at lists.omnis-dev.com>, wrote:
> Ok, so your sending a row to save...YES
>
> so send the row as a parameter...I SEND
>  then the method in the main window can
> save it for you... THE RECORD IS SAVED
> why wouldn't that work...IT WORKS
> This is not the problem I have.
> I have a SECOND window doing the same SAVE method.
> Instead of copying the save method from FIRST window
> Is there a way to call the save method from the FIRST window from the SECOND window?
>
> I give up!
>
>
> On Friday, January 6, 2023 at 06:02:00 PM GMT+3, Phil (OmnisList) <phil at pgpotter.co.uk> wrote:
>
> Hi Martin,
>
> Ok, so your sending a row to save...
> so send the row as a parameter, then the method in the main window can
> save it for you...
> why wouldn't that work...
>
> regards
> Phil Potter
> Based in Chester in the UK.
>
> On 06/01/2023 14:03, Martin Obongita via omnisdev-en wrote:
> >   Hi Phil
> > I have two windows with buttons to save records to the same table/schema.
> > Should the methods in the 2 save buttons be duplicated?
> > Or there is a way I can call the same save method from two the two windows?
> >
> > I hope my question is now clearer.
> > Martin
> >
> >
> >
> >       On Friday, January 6, 2023 at 04:47:05 PM GMT+3, Phil (OmnisList)<phil at pgpotter.co.uk>  wrote:
> >
> >   Hi Martin,
> >
> > So why can't any sub window call the main window method and get the list
> > it returns?
> >
> > Surely it can, and there are no limitations?
> >
> > I'm not sure I understand your query?
> >
> > regards
> > Phil Potter
> > Based in Chester in the UK.
> >
> > On 06/01/2023 13:01, Martin Obongita via omnisdev-en wrote:
> > > > Hi All,
> > > > I have a sub window that fetches a list from a table class by calling a method in the main window.
> > > > $cwind.$getDataList
> > > > I would wish to fetch the same list from the same table but in a different sub window.
> > > > I do not want to copy the method from one window to another.
> > > > Is there a function that can call a method in a main window(A) from a sub window of main window (B)?
> > > > I cannot inherit the window because Window (B) is performing a different function.
> > > >
> > > > Kind regardsMartin Obongita
> > > >
> > > >
> > > > _____________________________________________________________
> > > > Manage your list subscriptions athttps://lists.omnis-dev.com
> > > > Start a new message ->mailto:omnisdev-en at lists.omnis-dev.com
> > _____________________________________________________________
> > Manage your list subscriptions athttps://lists.omnis-dev.com
> > Start a new message ->mailto:omnisdev-en at lists.omnis-dev.com
> >
> > _____________________________________________________________
> > Manage your list subscriptions athttps://lists.omnis-dev.com
> > Start a new message ->mailto:omnisdev-en at lists.omnis-dev.com
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
_____________________________________________________________
Manage your list subscriptions at https://lists.omnis-dev.com
Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com

_____________________________________________________________
Manage your list subscriptions at https://lists.omnis-dev.com
Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com

[https://carrubba-image.s3-us-west-2.amazonaws.com/logo_smaller.png]




More information about the omnisdev-en mailing list