We are in process of planning a cross platform application and are eager to use Silver.
At this moment we are discussing the database backend of the application for iOS, Windows and Android. We are discussing two solutions, each with their pros and cons.
First approach is use the existing frameworks on the specific platforms. So voor iOS CoreData, Windows Entity Framework and Androids framework (Which is??)
Big plus for this solutions is that you can use the power of the frameworks. On the other hand some glueing code/layer is needed to achieve a cross platform approach.
For instance a Person entity could be designed as follows:
class Person #if NOUGAT :NSManagedObject #elseif ECHOES : Entity #endif {
#if NOUGAT @NSManaged #endif var name : String?
#if NOUGAT @NSManaged #endif var address : String?
}
Admit, not the most clear code, but it could work. (Have to note that Silver at this moment does not allow this compiler directives)
A second approach would be to implement a crossplatform data access layer on top of SQLite and other database backends. A big disadvantage is that it would be a project on its own. We did it before but I am not sure if I want to go through that hassle once again.
An adventage would be that you could build this mostly X-platform.
Just some thoughts from us, Would like to hear your opinions/thoughts on this!
One other option would be to look at our Data Abstract product — especially if you are looking at ding server-side data, not just local storage.
you could even define @NSManaged to be a dummy attribute that does nothing, for Java and .NET, and do away with all the #ifs altogether, since both Java and .NEt support defining custom attributes.
it does, FTR. but C-style # directives need to go on their own line, you cannot use them inline. that won’t change, i’m afraid. i.e.
#if NOUGAT
@NSManagedObject
#elseif
class Person ECHOES : Entity #endif {
#if NOUGAT
@NSManaged
#endif
var name : String?
...
would work (but yes, is even more ugly ;).
this would be a cool project to have though. i think if a couple more Silver users could get on board to work on this, and with our help and contribution as well, this could be a nice open source library useful many many Silver users.
Another option would be to take an open source library that suits your needs, say for example SQLitePersistentObjects, and then adapt it across platforms, which should involve relatively minor changes, probably just replacing the Cocoa runtime library calls to create objects and set their properties, etc, programmatically to a common library that works for any platform.
This is the approach I’m planning on taking for various libraries. It should get easier the more you do it since you only need to write the “glue” code once and can reuse it. It ends up the reverse of something like Sugar in that the original platform of the library becomes the interface for a common implementation rather than an abstracted one.