coding

Today, I again ran in a QASSERT(). The problem with an assert is that the software stops and voilà. Yes. The assert has a message telling me what happened (why it is asserting) and the location of the assert.

So I know it was a QList problem because of an out of range index. Good.

Only, to fix said problem, you need the location of the caller. Knowing that an assert was generated in qlist.h is hardly helpful.

Of course, most of you will say: just run your software in your debugger, then it will break when the assert happens. True, unless the assert happens in a child process you ...

The controlled_vars library allows you to define variables that you never initialize. This is very practical if you have a large number of variables or a large number of objects of a class.

The idea is pretty simple and once you remove the debug, the variable becomes 1 to 1 equivalent to a char, unsigned char, signed char, short, unsigned short, int, unsigned, long, unsigned long, etc. In other words, it goes really fast.

However, in debug mode, the class adds a bool to know whether the variable was initialized or not. If not yet initialized, you cannot read the value or you get an ...

As I was checking some code, I though that I should write a note about good and bad practices.

When you create a table entry and want to use a form of status (or whatever other type of multi-state entry with a fairly small selection such as the sex of a person) you often think of using an enumeration or at least an integer. For a status, you could use 0 meaning off and 1 meaning on. Maybe you have a third status: 2, meaning it is on and shows a form to the user.

In general, this works as a great optimization. If you use a string such as "on", "off", "with-form", ...

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly