Saving data/settings

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Saving data/settings

pink
I'm interested in learning how people save data and settings for applications, especially on mobile devices.

The method I have been using is to create an invisible data stack and save the data as custom properties. I like this the most because I tend to put most of my data and settings into arrays, and this requires the least amount of steps and no encoding to read and write.

Reading and writing to a text file also works, but does require some sort of encoding and decoding to save arrays.

I've experimented a little bit with local database files. In particular I've tried Andre Garzia's database library, and Livecloud's local database, both of which are pretty nice.

I'm curious what everyone else uses, and what do you think are the pros and cons of different methods?

---
Greg (pink) Miller
mad, pink and dangerous to code
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

Mike Kerner
I put everything in a db, and I have default settings coded into the app to
populate the db.  You don't need Andre's library to use DB's with LC (and I
do not).  db access in LC is very easy (but that is not to say that his
library won't make it easier).  In fact, db access in LC is so easy that I
don't use files or extra stacks for anything.  The only time I do use
read/write files is when I am sending them to the cloud or retrieving them
from the cloud.  This is a very effective way to do data transport to and
from mobile.

On Wed, Dec 7, 2016 at 10:14 AM, pink <[hidden email]> wrote:

> I'm interested in learning how people save data and settings for
> applications, especially on mobile devices.
>
> The method I have been using is to create an invisible data stack and save
> the data as custom properties. I like this the most because I tend to put
> most of my data and settings into arrays, and this requires the least
> amount
> of steps and no encoding to read and write.
>
> Reading and writing to a text file also works, but does require some sort
> of
> encoding and decoding to save arrays.
>
> I've experimented a little bit with local database files. In particular
> I've
> tried Andre Garzia's database library, and Livecloud's local database, both
> of which are pretty nice.
>
> I'm curious what everyone else uses, and what do you think are the pros and
> cons of different methods?
>
>
>
>
>
> --
> View this message in context: http://runtime-revolution.
> 278305.n4.nabble.com/Saving-data-settings-tp4710911.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

Mike Kerner
I would check the examples that LC has for db access.  I wound up rolling
my own db library afterward just because I wanted things to be a certain
way, but like I said, it's so easy to use DB's in LC that it's not worth it
not to.  When it comes to building your db structures, take a look at
Valentina.  You can build them on your desktop, then have them included in
the "copy files" with your app.  That would be another way to have default
values included with your app - you would have them set in the db that gets
copied with the app.  Valentina is currently my favorite dbms tool.

On Wed, Dec 7, 2016 at 10:40 AM, Mike Kerner <[hidden email]>
wrote:

> I put everything in a db, and I have default settings coded into the app
> to populate the db.  You don't need Andre's library to use DB's with LC
> (and I do not).  db access in LC is very easy (but that is not to say that
> his library won't make it easier).  In fact, db access in LC is so easy
> that I don't use files or extra stacks for anything.  The only time I do
> use read/write files is when I am sending them to the cloud or retrieving
> them from the cloud.  This is a very effective way to do data transport to
> and from mobile.
>
> On Wed, Dec 7, 2016 at 10:14 AM, pink <[hidden email]> wrote:
>
>> I'm interested in learning how people save data and settings for
>> applications, especially on mobile devices.
>>
>> The method I have been using is to create an invisible data stack and save
>> the data as custom properties. I like this the most because I tend to put
>> most of my data and settings into arrays, and this requires the least
>> amount
>> of steps and no encoding to read and write.
>>
>> Reading and writing to a text file also works, but does require some sort
>> of
>> encoding and decoding to save arrays.
>>
>> I've experimented a little bit with local database files. In particular
>> I've
>> tried Andre Garzia's database library, and Livecloud's local database,
>> both
>> of which are pretty nice.
>>
>> I'm curious what everyone else uses, and what do you think are the pros
>> and
>> cons of different methods?
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://runtime-revolution.2783
>> 05.n4.nabble.com/Saving-data-settings-tp4710911.html
>> Sent from the Revolution - User mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
>
> --
> On the first day, God created the heavens and the Earth
> On the second day, God created the oceans.
> On the third day, God put the animals on hold for a few hours,
>    and did a little diving.
> And God said, "This is good."
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

Dr. Hawkins
In reply to this post by Mike Kerner
On Wed, Dec 7, 2016 at 7:40 AM, Mike Kerner <[hidden email]>
wrote:

> In fact, db access in LC is so easy that I
> don't use files or extra stacks for anything.
>

same here.

SQLite is buit in.

In fact, i use it with a :memory: file for data, two--on loading a client,
it gets the data from a postgreSQL server, stashes it in memory, and
periodically updates the external server.  Not for most uses, but being
able to SELECT/WHERE was compelling for me.



--
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

Richard Gaskin
In reply to this post by pink
pink wrote:

 > I'm interested in learning how people save data and settings for
 > applications, especially on mobile devices.
 >
 > The method I have been using is to create an invisible data stack
 > and save the data as custom properties. I like this the most because
 > I tend to put most of my data and settings into arrays, and this
 > requires the least amount of steps and no encoding to read and write.
 >
 > Reading and writing to a text file also works, but does require some
 > sort of encoding and decoding to save arrays.
 >
 > I've experimented a little bit with local database files. In
 > particular I've tried Andre Garzia's database library, and
 > Livecloud's local database, both of which are pretty nice.
 >
 > I'm curious what everyone else uses, and what do you think are the
 > pros and cons of different methods?

There are may ways to store data, each with its strengths and weaknesses.

I don't believe in "best", a "one size fits all" that'll cover every
need.  App requirements are far too varied to limit oneself to just one
storage method.

"Best" is what's best for your data structures.

If you need to store LC objects, you'll want to use a stack file.

If your data is a good fit for "normalization" via relational tables,
use SQLite for local storage, or MySQL or postpreSQL for servers.

If your data can be well expressed with key-value pairs, use arrays
locally, and a key-value store like CouchDB or MondgoDB for servers (I
hear there's a great library available for using CouchDB in LC <g>).

With any of them, it'll probably be useful to write getter/setter
accessor handlers for them, so all the specifics of access are handled
in one place. With accessors, you can write just a single line to get or
put data anywhere throughout your code.

With that convenience in place, you won't need to worry about things
like arrayDecode/arrayDecode, you can just include those in the
accessors you'll need to handle path stuff and other details, so
everything is in one place.

Sufficiently generalized accessors may even allow you to change the
storage mechanism later on without changing any other code beyond those
two accessors.

Lots of options.  Total freedom.  The world is your oyster.

Let your app's business logic be your guide.  Choose the storage model
that fits your data structures, not the other way around.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

Mark Talluto-3
In reply to this post by pink

> On Dec 7, 2016, at 7:14 AM, pink <[hidden email]> wrote:
>
> I've experimented a little bit with local database files. In particular I've
> tried Andre Garzia's database library, and Livecloud's local database, both
> of which are pretty nice.
>
> I'm curious what everyone else uses, and what do you think are the pros and
> cons of different methods?

*Quick disclosure: I work on the CassiaDB/LiveCloud project.

For most of our local data storage we use CassiaDB (database that powers LiveCloud). Databases are nice for a number of reasons. They manage all the gory details for robust storage. Performance is better as a norm due to optimizations in the way data is managed. Query is a big plus. Updating data is easy. Reading specific data is useful. Keep in mind that you can store both text and binary data in a database. This would include LiveCode controls. I dare say, "Databases are cool". Bet you do not hear that often. :)

Sometimes JSON documents are useful. This would be for interoperability with other technologies. MergJSON works really well and allows arrays to be preserved to disk. Plus this gives one an in with other databases like MongoDB and CouchDB ;). We use JSON for our config file in CassiaDB.

LSON is the format used by CassiaDB when data is cached to disk. It is a performant format as it is native to LiveCode.

In the past it was common for us to use XML. Text file storage is human readable and builds confidence when just starting out with a new project. Testing what you save to the file can be verified easily with a text editor pointing to said file.

I would agree with the others that learning to use a database will be worth the effort in the end. There are many options available to LiveCode developers. Here are a few off the top of my head *that have LiveCode friendly APIs available*:  Valentina, SQLite, CouchDB (thanks to Pink), various SQLs, and CassiaDB.

Best regards,

Mark Talluto
livecloud.io <http://www.livecloud.io/>
canelasoftware.com <http://www.canelasoftware.com/>



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

Alex Tweedly
In reply to this post by Richard Gaskin


On 07/12/2016 17:13, Richard Gaskin wrote:
> If your data can be well expressed with key-value pairs, use arrays
> locally, and a key-value store like CouchDB or MondgoDB for servers (I
> hear there's a great library available for using CouchDB in LC <g>).
>
Could you perhaps say more about that  ?
Where can it be found ?

Thanks
Alex
P.S. yes, I did look first :-) Google only found me a couple of
forum/uselist threads telling me why I shouldn't want this :-)



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

prothero@earthlearningsolutions.org
On this subject, I am wondering about the best way to make user entered data persist between upgrades, on mobile. On an app I made for myself, I store it to my personal server, but for wider distribution, I've been planning on Dropbox, since livecode supports it. Are there other options that you would suggest!

Bill

William Prothero
http://es.earthednet.org

> On Dec 7, 2016, at 10:28 AM, Alex Tweedly <[hidden email]> wrote:
>
>
>
>> On 07/12/2016 17:13, Richard Gaskin wrote:
>> If your data can be well expressed with key-value pairs, use arrays locally, and a key-value store like CouchDB or MondgoDB for servers (I hear there's a great library available for using CouchDB in LC <g>).
>>
> Could you perhaps say more about that  ?
> Where can it be found ?
>
> Thanks
> Alex
> P.S. yes, I did look first :-) Google only found me a couple of forum/uselist threads telling me why I shouldn't want this :-)
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

pink
In reply to this post by Alex Tweedly
CouchDB Library is here:
https://github.com/madpink/couchdb4livecode

Forum thread here:
http://forums.livecode.com/viewtopic.php?f=12&t=24925&hilit=couchdb
---
Greg (pink) Miller
mad, pink and dangerous to code
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

Richard Gaskin
In reply to this post by Alex Tweedly
Alex Tweedly wrote:

 > On 07/12/2016 17:13, Richard Gaskin wrote:
 >> If your data can be well expressed with key-value pairs, use arrays
 >> locally, and a key-value store like CouchDB or MondgoDB for servers
 >> (I hear there's a great library available for using CouchDB in LC
 >> <g>).
 >>
 > Could you perhaps say more about that  ?
 > Where can it be found ?

It's Greg's ("Pink"); I was having fun with him because of course I know
he knows about it. :)

He's done some fine work on it.  There's a forum thread about it, which
includes a link to the Github repo:
http://forums.livecode.com/viewtopic.php?f=12&t=24925


 > P.S. yes, I did look first :-) Google only found me a couple of
 > forum/uselist threads telling me why I shouldn't want this :-)

Lots of good fodder in the SQL-vs-nonSQL debate.

My favorite is Sarah Mei's oft-cited blog post, "Why You Should Never
Use MongoDB":
<http://www.sarahmei.com/blog/2013/11/11/why-you-should-never-use-mongodb/>

She raises some excellent points, told with real-word stories to back
'em up, and I agree with everything she wrote.

I still use key-value stores where they're a good fit, but at least I'm
aware of the trade-offs.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

J. Landman Gay
In reply to this post by prothero@earthlearningsolutions.org
This isn't much of an issue on mobile. An update will change the app
itself but not touch the user data. You can store it in the Documents
folder and it will stay there, no need for cloud storage unless your app
requires that for some reason.

On 12/7/16 12:43 PM, [hidden email] wrote:
> On this subject, I am wondering about the best way to make user
> entered data persist between upgrades, on mobile. On an app I made
> for myself, I store it to my personal server, but for wider
> distribution, I've been planning on Dropbox, since livecode supports
> it. Are there other options that you would suggest!
>
> Bill


--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

prothero@earthlearningsolutions.org
Jacqueline,
Thanks. Worrying about nothing.
Bill

William Prothero
http://es.earthednet.org

> On Dec 7, 2016, at 11:11 AM, J. Landman Gay <[hidden email]> wrote:
>
> This isn't much of an issue on mobile. An update will change the app itself but not touch the user data. You can store it in the Documents folder and it will stay there, no need for cloud storage unless your app requires that for some reason.
>
>> On 12/7/16 12:43 PM, [hidden email] wrote:
>> On this subject, I am wondering about the best way to make user
>> entered data persist between upgrades, on mobile. On an app I made
>> for myself, I store it to my personal server, but for wider
>> distribution, I've been planning on Dropbox, since livecode supports
>> it. Are there other options that you would suggest!
>>
>> Bill
>
>
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Saving data/settings

Tom Glod
I arrayencode...compress .....then binaryencode into straight up text file
or field

On Wed, Dec 7, 2016 at 2:15 PM, [hidden email] <
[hidden email]> wrote:

> Jacqueline,
> Thanks. Worrying about nothing.
> Bill
>
> William Prothero
> http://es.earthednet.org
>
> > On Dec 7, 2016, at 11:11 AM, J. Landman Gay <[hidden email]>
> wrote:
> >
> > This isn't much of an issue on mobile. An update will change the app
> itself but not touch the user data. You can store it in the Documents
> folder and it will stay there, no need for cloud storage unless your app
> requires that for some reason.
> >
> >> On 12/7/16 12:43 PM, [hidden email] wrote:
> >> On this subject, I am wondering about the best way to make user
> >> entered data persist between upgrades, on mobile. On an app I made
> >> for myself, I store it to my personal server, but for wider
> >> distribution, I've been planning on Dropbox, since livecode supports
> >> it. Are there other options that you would suggest!
> >>
> >> Bill
> >
> >
> > --
> > Jacqueline Landman Gay         |     [hidden email]
> > HyperActive Software           |     http://www.hyperactivesw.com
> >
> > _______________________________________________
> > use-livecode mailing list
> > [hidden email]
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode