Yep - I think that's where the analogy falls down.but of course we are limited to the predefined ones.
Data objects
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Data objects
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 9655
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Data objects
Just as I have been building things for 36 years.
But again, can widgets be the new "object class", er, object class?
Craig
But again, can widgets be the new "object class", er, object class?
Craig
Re: Data objects
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...
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Data objects
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.
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.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- Livecode Opensource Backer
- Posts: 9361
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Data objects
Why can we not clone a template field object, rename it, and then muck around with it to create a new object?
-
- VIP Livecode Opensource Backer
- Posts: 9655
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Data objects
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
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
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Data objects
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>
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>
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Data objects
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?
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Data objects
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?
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?
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 9655
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Data objects
Mark.
Craig
You can, though. Custom properties are just properties. They do not survive sessions, though.You can't create new custom properties of template objects
Craig
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Data objects
Hah! I had tried this before posting that message and it didn't work, now it does.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 9655
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Data objects
More trivia.
If I
and then create a new button by pulling from the tools palette, the custom property sticks, but not the height. But if I
both stick.
Craig
If I
Code: Select all
set the height of the templateButton to 100
set the XYZ of the templatebutton to "123"
Code: Select all
create button
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9655
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Data objects
Mark.
????????????
Craig
What do you mean??? Are you saying that there are evil spirits lurking in LC, or in our minds, or both???????Hah! I had tried this before posting that message and it didn't work, now it does.
????????????
Craig
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Data objects
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.
I'll keep you in mind for the next time some of my code doesn't work.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Data objects
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn