Data objects

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Data objects

Post by mwieder » Mon Jan 30, 2023 7:39 pm

but of course we are limited to the predefined ones.
Yep - I think that's where the analogy falls down.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Data objects

Post by dunbarx » Mon Jan 30, 2023 9:19 pm

Just as I have been building things for 36 years.

But again, can widgets be the new "object class", er, object class?

Craig

stam
Posts: 2599
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Data objects

Post by stam » Tue Jan 31, 2023 1:37 am

Craig makes a good point. If I'm not mistaken we should soon be able to constructs 'widgets' directly in LC, this seems to fill that brief...

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Data objects

Post by mwieder » Tue Jan 31, 2023 3:02 am

Widgets would also be in much the same category as the built-in objects in as much as a set of pushButton controls would all act similarly, given the properties and functions of the base pushButton widget.

But where some of the real power of classes comes in is that modifications to the original object will affect any of the child objects. And that's part of where the analogy to object-oriented programming falls apart, because we can't modify a generic field object in ways that will affect fields based on it (and we'd be in serious trouble in LiveCodeLand if that were so). And I think that's where the power of behaviors comes into play.

More class-like functionality can come from (for instance) creating a group of buttons, pointing them all to a common behavior script, and then changes to the behavior script later on will affect the entire "class" of buttons that are linked to it. In any event this will all be somewhat imperfect because we're trying to graft object-oriented programming onto an environment that doesn't natively support it.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Data objects

Post by richmond62 » Tue Jan 31, 2023 1:29 pm

Why can we not clone a template field object, rename it, and then muck around with it to create a new object?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Data objects

Post by dunbarx » Tue Jan 31, 2023 3:02 pm

Richmond.

How does that create a new object class? The templateWhatevers are terrific gadgets, but they only preset one or more properties of the object class they designate. They are wonderful shortcuts, not anything new.

Craig

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Data objects

Post by mwieder » Tue Jan 31, 2023 5:23 pm

Yes, Craig nailed it. The template objects only act as sort-of classes at the time of creating new objects.
You can't create new custom properties of template objects and you can't add new handlers to them - you can only act on a predefined list of properties. And maybe more importantly, if you change a property of a templateField it doesn't affect any existing fields, just the ones you create afterwards.

That's where behaviors can come in handy as another kins of sort-of classes.
If you create a bunch of fields and you want to add a foo() function to one you modify its script.
But if you want all of them to have the foo() function you could just modify the behavior script they all have in common.

If you have a lot of those fields this not only saves a lot of effort, but if you make a mistake you only have to correct it once. <g>

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Data objects

Post by FourthWorld » Tue Jan 31, 2023 5:39 pm

Not all languages are OOPs.

In this non-OOP language, would this request for automated data handling not bound to specific UI elements be implementable with a library that creates and manages specific arrays as though they're structs?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Data objects

Post by mwieder » Tue Jan 31, 2023 5:52 pm

Well, this is LiveCode, so anything's possible, no?

I still think I'd use a database for the OP's person object, but...

would placing getprop and setprop handlers in a behavior script do the proper data binding for that?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Data objects

Post by dunbarx » Tue Jan 31, 2023 6:57 pm

Mark.
You can't create new custom properties of template objects
You can, though. Custom properties are just properties. They do not survive sessions, though.

Craig

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Data objects

Post by mwieder » Tue Jan 31, 2023 7:03 pm

Hah! I had tried this before posting that message and it didn't work, now it does.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Data objects

Post by dunbarx » Tue Jan 31, 2023 7:04 pm

More trivia.

If I

Code: Select all

set the height of the templateButton to 100
set the XYZ of the templatebutton to "123"
and then create a new button by pulling from the tools palette, the custom property sticks, but not the height. But if I

Code: Select all

create button
both stick.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Data objects

Post by dunbarx » Tue Jan 31, 2023 7:06 pm

Mark.
Hah! I had tried this before posting that message and it didn't work, now it does.
What do you mean??? Are you saying that there are evil spirits lurking in LC, or in our minds, or both???????

????????????

Craig

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Data objects

Post by mwieder » Tue Jan 31, 2023 7:09 pm

Yep - it's obvious that your post was the magic incantation that got things working.
I'll keep you in mind for the next time some of my code doesn't work.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Data objects

Post by FourthWorld » Tue Jan 31, 2023 7:36 pm

mwieder wrote:
Tue Jan 31, 2023 5:52 pm
I still think I'd use a database for the OP's person object
I wonder if Trevor's SQLYoga would be a good fit here. It treats data connectors as property -driven virtual objects.

https://github.com/trevordevore/sql-yoga/wiki
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”