Strategies for reducing programming errors
Use ASSERT
Use ASSERTAlthough I haven't done this myself within wxWidgets, it is good practice to use ASSERT statements liberally, that check for conditions that should or should not hold, and print out appropriate error messages. These can be compiled out of a non-debugging version of wxWidgets and your application. Using ASSERT is an example of 'defensive programming': it can alert you to problems later on.
Use wxString in preference to character arraysUsing wxString can be much safer and more convenient than using wxChar *. Again, I haven't practiced what I'm preaching, but I'm now trying to use wxString wherever possible. You can reduce the possibility of memory leaks substantially, and it is much more convenient to use the overloaded operators than functions such as strcmp. wxString won't add a significant overhead to your program; the overhead is compensated for by easier manipulation (which means less code). The same goes for other data types: use classes wherever possible.
|