[GNC-dev] Preferred way of writing object oriented code

Maarten Bosmans <[email protected]>
Newsgroups gmane.comp.gnome.apps.gnucash.devel
Message-ID <CA+CvcKT96uNkgYukCo1Tve6yZeOCT0TbiCy7ARa5iTonTMtrDw@mail.gmail.com>
Hi,

In preparation for making some changes to QuickFill.c, I thought it
would be a good idea to get familiar with the GnuCash code by doing
some easy fixes or code improvements.
So I turned on the AddressSanitizer of GCC and ran the test suite. The
first issue I looked at was a delete of a GncGuid that was allocated
with g_malloc(). Trying to untangle that led me through several
parallel implementations of objects and containers: GLib, Qof, and
C++. Let's just say that the codebase has a rich and varied history.

Of course this is not new to any current developers of GnuCash. On C++
page on the wiki it is mentioned that C++ should be preferred over
GLib and Qof. I think that makes sense.
I have a couple of questions for further clarification, as I want to
avoid spending time on preparing patches that you don't want to
accept.
 - I see that GncGuid is implemented using boost::uuid now. But the
implementation still interfaces with glib and qof. Is eliminating that
seen as a worthwhile further improvement? (even if it is just
replacing `gconstpointer` with `const *void`)
 - Could in general any GList instance that is not needed for
interfacing with Gtk potentially be converted to the appropriate C++
container?
 - Does this also mean that any .c file can be converted to .cpp if we
need to make use of a C++ feature? (e.g. std::vector, or templated
functions)

Maarten
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.