Debugging Clever Code
by gmosx in Dogma, at 15-4-2009
Debugging is twice as hard as writing the code in the first place.Brian Kernighan
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

Debugging is twice as hard as writing the code in the first place.Brian Kernighan
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.




var Database = require("database/rdb").Database;
var db = new Database("jdbc:mysql://localhost/example?user=nitro&password=p@ssw0rd");
// pre-prepare the statement
var sql = db.prepare("INSERT INTO Article (title, body) VALUES (?, ?)");
var id;
for (var i = 0; i < 10; i++) {
// use the prepared statement.
id = db.insert(sql, "title " + i, "body " + 1);
print("inserted: " + id);
}
// query for one object.
var article = db.query("SELECT id, title FROM Article WHERE id=?", id).one();
print("title: " + article.title);
// query for many objects.
var articles = db.query("SELECT id, title FROM Article WHERE id>?", 20).all();
print("length: " + articles.length);
var Article = function(title, body) {
this.title = title;
this.body = body;
}
Article.prototype.dummy = function(extra) {
return "---> " + this.title + " : " + extra;
}
// query for many objects, deserialize in a specific JavaScript object 'class'.
var articles = db.query("SELECT id, title FROM Article WHERE id>? LIMIT 5", 20).all(Article);
for (var a in articles) {
print(articles[a].dummy("this is extra"));
}
// use a result iterator for optimized result processing.
var articles = db.query("SELECT id, title FROM Article WHERE id>? LIMIT 5", 20).each(function(a) {
print("*** " + a.dummy("forEach"));
}, Article);







The secret of happiness is simple: find out what you truly love to do and then direct all of your energy towards doing it. Once you do this, abundance flows into your life and all your desires are filled with ease and grace.The Monk Who Sold His Ferrari


var args = Array.prototype.splice.call(arguments, 0);






If you constantly compare yourself to others, then all you’ll ever be is
just as good as them, maybe a little better. You’ll also miss out on all
the fantastic things you might actually be good at while you’re focused on
being better than them at what they’re good at.

Latest comments