I prefer to keep 2 parameters: obhject and form event That way I can emulate object events outside the objects. eg MyGenericObjectMetod( ->bAccept, On Clicked) to emulate a click on my accept button
On Thu, Apr 25, 2019 at 4:31 PM Herr Alexander Heintz via 4D_Tech < [email protected]> wrote: > I absolutely agree with Chip! > For quite some time I have made sure all code called by objects is 1 line > only! > Now, with ORDA and the Form. object, it gets even easier to do this! > Also in many cases there is no neeed for parameter passing: > Using > > OBJECT Get name(Object current < > https://doc.4d.com/4Dv17R5/4D/17-R5/Form-Objects-Access.302-4127247.en.html > >) > and > Current form name > > makes life so much simpler... > > Also: > No form object should have an „on load“ event!!! > The call order of the On Load event makes it quite difficult, especially > if some things rely on others. > Run it all in the Forms On Load event. > BTW: Using the Form.whatever notation for Checkboxes and Radio Buttons > will accept Boolean values. > You can assign From.myBoolean to a checkbox… > Oh how much easier would life have been with all the V17 Stuff… > > Cheers > Alex > > > > Am 25.04.2019 um 16:22 schrieb Chip Scheide via 4D_Tech < > [email protected]>: > > > > Chris B made the below statement about project methods. > > > > from a 'classic' 4D pogromming view, IMHO - which may mean nothing :), > > this is not the approach I use or advocate. > > > > I do use object methods - but - only to call project methods which do > > all of the actual work. > > ex: accept button script > > // accept button script <[table].form.object> > > tablename_entry_accept > > // end accept button script <[table].form.object> > > > > the project method tablename_entry_accept will do data entry > > validation, messaging about entry failures, related record existence, > > calculations that need to be done etc. and usually an ACCEPT > > > > > > Why? > > Deduplication of code. Code should NOT be repeated. In the above > > example, the code to accept the form maybe reusable or be made more > > generic (with parameters). If the code for this accept button was > > placed in the object script - I might end up re-creating/repeating the > > code elsewhere (even to the point of copy/paste). > > > > At some point in the future I might need to change the logic/code. Then > > I would need to find all instances of the code through out the system, > > to make the change. If the system is NOT one I wrote, or it has been a > > long time (3 days?) since I worked on that section I would/might not > > know where all instances of the duplicated code are. > > > > If the code is in a project method, I can make the changes needed in > > one place, done. > > Also - code in scripts is harder to find/maintain. > > > > Some people in the past have advocated for removal of all object > > scripts, placing the code instead into the form method (or better the > > project method called by the form method). I do not personally do this, > > as I looked at it once and, to me, the resulting code was too long and > > not clear -- of course maybe I was not implementing the idea correctly > > or completely :) > > > > just my 2 cents > > > > Chip > > > > > > On Wed, 24 Apr 2019 22:37:51 -0600, Chris Belanger via 4D_Tech wrote: > >> > >> Another use for it that I have not explored yet is to have a chunk of > >> code that gets run under several different circumstances, but which I > >> don’t want to make a dedicated Project Method for it. > >> I prefer to reduce the number of Project Methods while, of course, > >> creating ones that make logical sense (as they can be called in > >> several places in my code). But you understand that as a programmer. > > --------------- > > Gas is for washing parts > > Alcohol is for drinkin' > > Nitromethane is for racing > > ********************************************************************** > > 4D Internet Users Group (4D iNUG) > > Archive: http://lists.4d.com/archives.html > > Options: https://lists.4d.com/mailman/options/4d_tech > > Unsub: mailto:[email protected] > > ********************************************************************** > > ********************************************************************** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:[email protected] > ********************************************************************** -- Jim Dorrance [email protected] [email protected] www.4d.dorrance.eu PS: If you know of anyone that needs an experienced 4D programmer to add energy and experience to their team, please let me know. I have experience in many areas. Reasonable rates. Remote or Paris only. ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

