avrò una prova:
Io tendo ad usare il mvc-pattern per sviluppare la mia applicazione in quanto l'attuazione di tutte cose in un unico js-file è abbastanza brutto. così ho deciso di utilizzare un file per la visualizzazione e tutte le cose che concedevano il look-and-feel, un file per la gestione del database (il controller), in particolare le istruzioni SQL e un file per lo abstract data type (il modello).
un breve esempio:
vista: viewConcerningObject.js
Ti.include('object.js');
var win = Ti.UI.currentWindow;
var myObject = new object();
var myObjectName = Ti.UI.createLabel({
text:myObject.getName();
});
win.add(myObjectName);
modello: object.js
Ti.include('controllerConceringObject.js');
function object(){
this.name = 'myInitialName';
this.getName(){
return this.name;
};
this.setName(newName){
this.name = newName;
};
this.updateNameFromDb(){
this.name = getNameFromDatabase();
};
}
regolatore: controllerConcerningObject.js
function getNameFromDataBase(){
var db = Ti.Database('objects');
var sql = 'SELECT name FROM objects';
var recordset = db.execute(sql);
var name = recordset.field(0);
recordset.close();
db.close();
return name;
};
così la struttura della cartella potrebbe essere simile a questo:
myProject: FolderView (viewConcerningObject.js), folderModel (theDatabase.db, object.js), folderController (controllerConcerningObject.js).
Si potrebbe anche provare commonJS: https://wiki.appcelerator.org/display/guides/Mobile+Best+Practices – Julian