get(???default???) == ???true???,
params :
if(p.exists(???file???))
p.get(???file???)
else
throw ???There is no database file for ?????? + el.get(???name???) + ?????™???
}
}
}
166
Part I: The Core Language
Assuming that the Config class is defined in the Config.hx file and that it resides in the default
package, the configuration class can be used as follows:
class Main
{
static function main()
{
var dbInfo = Config.getDatabase();
var conn = if(dbInfo.type == ???MySql???)
neko.db.Mysql.connect(dbInfo.params);
else if(dbInfo.type == ???Sqlite???)
neko.db.Sqlite.open(dbInfo.params);
else
throw ???Unsopported database ?????? + dbInfo + ?????™???;
// do something with the conn object
// ...
}
}
Because the Config class is used to open a database connection, it is obvious that this last example will
work just on the Neko platform.
Documenting Your Code
Documentation is a critical component of development when developers work in teams; but it is also
fundamental when a single developer wants to share his code with other developers and even in the
situation that the code is not meant to be redistributed, it can be a real pain to get back to an
undocumented code written a few months earlier.
Pages:
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333