Hi

This is a good point made by Paul...

> On 5 Oct 2018, at 09:15, Paul Dennis via 4D_Tech <[email protected]> wrote:
> 
> With tables and records and the structure it's relatively
> straightforward to track through the code and work out what's going on. I
> can see this being a real problem with objects. There just doesn't seem to
> be any visibility. The data could be buried many layers down in an object
> let alone all the quotes, dots and semi colons involved


I also agree with Kirk’s last post about unncecessary redundancy when you have 
a perfectly working programming paradigm already - and they do indeed take some 
documenting (at least in the code) - and you can get yourself tied in knots, 
especially when you go even one level of object hierarchy.

Despite that, I have recently taken the leap to using objects as arguments in 
methods and passing parameters “by name” rather than using $1..$N.

I did this because Laurent Ribardierre and JPR recommended this approach so 
categorically at the last advanced developers class. Also, when they demoed the 
new features of v17 and I saw the roadmap I can kind of see why - 4D want to 
drastically loosen the coupling between the forms layer, the code and the 
database engine. So what I’m doing now is just using a single object to hold 
all form properties that I’d previously used globals for. Then just use globals 
where required for active objects like menus.

You can preserve some of the formality of the old “$1…$2” approach by writing 
wrappers to “receive” the object properties and simultaneously “define” the 
form parameters - so that an error can be thrown is something’s missing from 
the mandatory argument list for example. But one of the advantages of this new 
approach I’ve noticed is massive flexibility when it comes to initialising the 
form. It’s much easier to refactor or add/remove parameters. (Say you had a 
function that opened the form and that function took some initial states as 
$1…$n. Just passing a single object instead saves having to support the 
argument list right up and down the call chain.

Also, I’m still on v15 but at the end of the day the new dot notation 
referenced object properties will not be much different from the old global 
variable approach.

Peter

**********************************************************************
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]
**********************************************************************

Reply via email to