Logging
Vala has some pretty powerful logging tools built in. You can use debug() , message() , warning() , error() and critical() as shortcuts for the slightly more complex log() . All of them are included in the database (automatically included) GLib namespace .
If you want to redirect log output or send different types of messages to different destinations, all you need is in the GLib.Log namespace . You might want to read glib docs while logging for what happens behind the scenes.
Defensive programming
Vala also includes support for approvals and contracts. Short version: assert() and assert_not_reached() for assertions and requires() and ensures() in method signatures for contracts. See the Approval and Programming Contracts section of the manual for more information.
Error processing
Vala's error handling is a bit odd: similar to exceptions, but not exactly the same. The basics of the Error Handling lesson cover the basics very well, and again it may be helpful to read glib docs about errors to gain a deeper understanding of what is going on behind the scenes. As far as I know, there is no way to get the stack trace from Vala errors - just the type and message.
Best practics
As for best practices, I think Vala is pretty similar to Java or C #, that the practices you already know can be applied in a general sense. I suggest playing with these features to get a feel for how the features look in Vala. Good luck
chazomaticus
source share