Bug free programming with Qt:
-
Yes, it's a big help, I've read the gitorious version, and I will the trolltech too later.
I'm teaching simple C at the University for newbies in this year (I'm an electrical engineer student) and it's very important and quite hard sometimes to teach them how to correctly indentation and style their code. But I'm getting much nicer codes now from them :) So it's worth to tell it a hundred times :)
-
Let's forget the "bug free" and rather talk about "robust" programming instead
- So, good coding style and conventions contribute to "robust" programming. And we have several links.
Other possible Qt's contributors to "robust" programming may be:
- signals & slots : for strong independency of components (+ impossible to crash even if bad coded ?)
- Implicit sharing and associated objects with reference counting
- Thread safe objects
Anything else ?
-
bq. (+ impossible to crash even if bad coded ?)
That your program does not crash, does not mean it has no bugs :-)
I agree to the other points though and think that the memory management things are most useful.
-
What do you mean with "memory management things" ? The shared classes ?
-
[quote author="laurent bauer" date="1293645469"]
- Implicit sharing and associated objects with reference counting
[/quote]
yes
- Implicit sharing and associated objects with reference counting
-
In the first post, i wrote: "You create an orphan widget, you attach it later to a parent widget. The parent takes ownership and you don’t need to worry anymore about the child life cycle"
I like this idea : you transfer the management of an object to an object owner. And you don't have to manage it yourself .
Do you know if this is a concept, a design pattern or anything which has a name?
Do you know if this coding way is described somewhere? -
The parent - child relationship, that includes lifetime coupling?
I would say it's a normal Komposition (UML :-) ).
-
So simple? Well, I feel a bit ridiculous...
-
Must everything be complicated?
-
In a sense, it is just an extension to the standard C++ behaviour to work with pointers (free on destruction) so it is not really a new concept.
-
OK, I guess a widget has a container of children widgets which are destroyed by the parent destructor.
However, it must be a little bit more tricky because the ownership can be transfered to another parent widget. -
It's only a QObjectList (which is just a typedef for QList<QObject *>). It is only little more than removing from one and inserting into the other list (and handling layout issues in case of widgets).
-
Yes, it's that simple :) The best things are so simple :)