Treeview conclusions

It looks like you guys are interested in loading three million rows in a GtkTreeView. Yesterday 512 (new) visitors visited our company subversion service to checkout the demo :-p. I think +- 100 people checked it out completely (the less obvious files, like Makefile.am’s, got viewed +- 90 times). That tops codegen‘s first day. Well, you can now put comments on my blog. So if you have questions about it: go ahead.

Note that I updated some files in the repository. Now it’s using a more correct way of implementing interfaces in C. The usage of the proxy pattern, thus implementing an interface, is actually the point of the demo. Sure is the wow cool thing about it that you can load millions of rows in a view. But the point is the proxy pattern. So it should be correct, if the intention is to ‘show’ how to do it. Right? Note that the proxy technique can be used in all sorts of model view controller situations. Not just for a treeview or datagrid.

In that demo, I should also do more with the proxy classes to show that you can treat them as if they are real subjects. That’s because they fulfill the contract (the interface) of the subject (a message header, in the case of the demo). Yet these proxy instances consume only 20 bytes. By the way, my favorite programming technique is strategy (I promised somebody not to use the word design pattern anymore. He felt design pattern is a buzzword). I’m likely going to do/show something with strategy sooner or later :-p. When browsing free software code, I often see “less good” designs decisions. Performance tweaking is very good but it wont help if the application developers aren’t going to use their brains before designing the application. The era of typical VB6 development should be over. A lot ‘managers’ should stop whining about KISS and first learn what it really means. KISS, like the KISS most people think KISS is, sucks. It doesn’t scale and it’s impossible to integrate unit testing and modern programming methods with it. The other KISS is a different story. Read Head First, Design Patterns and learn all about it. There, I’ve said it.

As a consultant I guess I got tired of manager-type guys who don’t have a clue, telling me to do everything KISS. Perhaps those guys should read about Peter Principle?! Sorry for this opinionated entry. I know I shouldn’t.

Auwch, I made a big mistake:

$ svn diff -r 14
Index: src/msg-header-proxy.c
=============================================================
--- src/msg-header-proxy.c      (revision 14)
+++ src/msg-header-proxy.c      (working copy)
@@ -76,7 +76,7 @@
 MsgHeaderProxy**
 msg_header_proxy_new_alot (gint amount)
 {
-       MsgHeaderProxy **proxies = (MsgHeaderProxy **) g_new (MsgHeaderProxy, amount);
+       MsgHeaderProxy **proxies = (MsgHeaderProxy **) g_new (MsgHeaderProxy*, amount);
        gint i=0;

        for (i=0; i < amount; i++)
$

Wow .. that would have been a total waste of memory AND a huge leak! Note that doing one huge allocation in stead of one allocation of a pointer-index-table followed by many g_slice_alloc, might improve the cpu usage a little bit (less expensive malloc syscalls). So perhaps it can be made even a little bit faster than the current result. Try it, send me a diff.