Tuesday, October 18, 2016

Dubbele domicilie? Graag!

Gisteren zat er een briefje van de postman in onze bus. Ik mocht een pakketje ophalen in het postpunt. Een verrassing, want ik had nergens iets besteld... leuk! Met een ietwat kindse nieuwsgierigheid begaf ik me vanavond naar het Texaco tankstation, vol verwachting. Teleurstelling alom toen het bleek te gaan om een aangetekend schrijven van de Federale Overheidsdienst Financiën. Plots had ik een 'Bericht van wijziging van aangifte' in mijn handen...

Nu... ik vind mezelf nogal pietje-precies. Dat hoort bij mijn job... beroepsmisvorming heet dat dan. In de wiskunde is 1+1=2 (tenzij we modulo twee rekenen, maar daar ga ik nu even niet dieper op in), en computercode faalt ook als je niet precies beschrijft wat het programma moet doen. Mijn federale fiscale administratie probeer ik dan ook jaar na jaar netjes en correct in te vullen. Tegenwoordig doet de hipster in mij dat zelfs online! Bahama's of andere exotische belastingsparadijzen, daar distancieer ik me van. Daar doe ik als brave, alleenstaande halftijdse papa niet aan mee. Ik wil vooral dat dingen correct verlopen. Correct is echter niet altijd makkelijk. Soms is correct zelfs moeilijker dan incorrect en moet je er moeite voor doen. Gelukkig schuw ik moeilijk niet. 'Moeilijk gaat ook', is wat mijn zoontje Jenne al vaak van mij heeft moeten horen. Heel af en toe durft hij me zelfs ook dat zinnetje toe te werpen als hij merkt dat ik ergens moeite mee heb. Het doet me glimlachen.

Even terug naar de brief... in die brief -die ik dus vandaag vol verrassing ontving- meldt men mij kort maar krachtig dat code 1034 van mijn aangifte NIHIL wordt omdat mijn zoon gedomicilieerd is bij zijn moeder. Nog korter samengevat: ik krijg dus geen belastingsvoordeel voor een zoon die ik met heel veel liefde halftijds opvoed en die nota bene ook gewoon de helft van de tijd bij mij verblijft.

Ik heb al heel wat gescheiden ouders ontmoet en gesproken, en kan me niet ontdoen van de indruk dat papa's zich na een scheiding om god-weet-welke reden op allerlei vlakken telkens weer méér moeten bewijzen dan mama's. Hoe vaak heb ik als vader al niet het gevoel gehad om me tegenover allerlei instanties en regeltjes te moeten verantwoorden of uitleggen? En hoe vaak komt het dan telkens weer niet neer op dat verdomde domicilie-adres? En zij het nu helaas zo dat een kind anno 2016 nog steeds slechts op één officiëel adres kan gedomicilieerd worden. Weze dat niet een beetje achterhaald en oneerlijk? Wie het domicilie-adres niet bezit, is precies de pineut... soms bijna zelfs de boeman... ongeacht opvoedkundige en andere capaciteiten.

Kan iemand me in godsnaam uitleggen waarom een kind in deze tijden van informatisering en digitale technologie, nog steeds niet gedomicilieerd kan worden op twee adressen? Is er dan op die hippe, digitale Kids-ID geen enkele byte meer over voor een tweede adres? Zou het niet goed en eerlijker zijn om onze federale en fiscale administratie toe te spitsen op de werkelijkheid van deze tijd, namelijk dat er heel wat kinderen in co-ouderschap worden opgevoed (ik durf de cijfers even niet op te zoeken...) En ware het niet uitstekend mocht een dubbele domicilie al heel wat twisten tussen gescheiden ouders oplossen? Psychologen en rechters hebben het vaak over 'Het Belang van het Kind'. Zou een dubbele domicilie het belang van het kind dan niet ten goede komen? Zowel administratief als emotioneel (minder gekibbel tussen papa en mama)?

Een goed jaar geleden wakkerde de discussie van de dubbele domicilie even op... Een snelle zoektocht op het net leert me dat er vanaf 2016 zoiets zou bestaan als een lokaal verblijfregister en dat is zeker een stap vooruit. Alleen... feit is en blijft dat dé domicilie nog steeds bij één enkele ouder staat. Het aangetekende schrijven dat ik vandaag ontving bevestigt dat dat nog steeds tot verwarring, oneerlijkheid en frustratie leidt, lokaal verblijfregister ten spijt.

Kunnen we daarom, beste beleidsmakers, even snel werk maken van een échte dubbele domicilie, waarbij de twee adressen evenwaardig zijn?

Monday, July 4, 2016

"C++ Standard Library Quick Reference" is out!

I'd love to write a book about C++ programming.  However, being in the solo-parenting business doesn't leave me much time to do that devotedly.  My son's clothes scream to get washed, our house needs some cleaning from time to time, someone (read 'daddy') has to do the dishes, and kids need playtime outside... so that's what I do... playing outside and being a would-be household man.

Fortunately, I've found an alternative to writing C++ books, namely reviewing them.  It takes less time, and pushes me to explore new C++ horizons.  It allows me to learn while doing something useful.  My 'reviewing career' (what's in a name ;-) started in 2013 when I reviewed Scott Meyers his 'Effective Modern C++' book.  For me, it was quite a tough read, but I enjoyed it and I was getting quite some satisfaction out of it.

About a year later, Rainer Grimm asked me if I wanted to review his 'C++, die Standardbibliothek: kurz & gut' in German.  I didn't hesitate a second.  Rainer has a rather different writing style then Scott (and he writes in German of course ;-), making this review again a challenging but enjoyable experience.

Earlier this year, Peter Van Weert and Marc Gregoire (the second one being a former fellow computer science student of mine) asked me if I was interested in reviewing their 'C++ Standard Library Quick Reference'.  Needless to say I was happy they asked.  About half a year later, the book is out!  It's cool to see how I also get my credits on page XVII :-)


I try to dedicate all my reviewing work to my now 6-year-old son Jenne, using small easter eggs in the books I review.  I always kindly ask the authors if they want to add my and my son's name in one of their code examples. Up until now, not a single author has refused that request.  It looks like this on page 71 of the book:

Pretty cool, huh!  Although Jenne starts to like programming with Scratch and LEGO WeDo 2.0, he currently doesn't know a clue about C++.  I hope some day, he will understand the message I sent him through these easter eggs.  It's a message of hope, dedication, perseverence and true love for the child whom I care about so much.

Thursday, June 9, 2016

Getting the code snippets on the blog...

Just testing

This evening, I finally took the time to investigate how to include code snippets into my blog posts. After some googling, I decided to use SyntaxHighlighter. If you see a hello world program below this paragraph, then all went well. Stay tuned for more snippets!

Wednesday, March 9, 2016

Survival tips for the solo-parenting dad, part 1 of N.

Being a solo-parenting dad can be daunting at times, especially when your cooking experience is limited and you need to prepare a meal for your 6-year-old son.  Yesterday, I took the challenge.  I decided to prepare a nice, healthy meal for my kiddo, who was forced to stay at home from school because of the flu.  Sad but true, he didn't enjoy staying at home, he missed his friends.  That's what kiddos do: they miss their friends.

Luckily, his dad is an optimist and decided to cook hamburgers with potatoes and some carrots... a typical Belgian dish that is.  I peeled and cut the potatoes while Jenne, my son, cut the carrots in thousand pieces (actually, according to him, there were a million pieces, but that was just him eggagerating...)  Once that was finished, I decided it was time to put both items on the stove, make the potatoes boil like hell and stew the carrots like i never stewed before.  Somewhere in between, I also fried my hamburgers: one with and without cheese for me, one without cheese for Jenne (the 6-year-old kiddo having the flu and missing his friends).

It was plain fun.  Jenne even forgot about the flu and his friends.  He looked happier than ever before, having cut and peeled his own carrots in more than a million pieces... the carrots he was going to eat within a few minutes.  His own, very own carrots!

But then... the unexpected happened...  While I started to pound on my potatoes to turn them into a nice and cosy purée, I somehow noticed the smell of burnt food.  A quick glance at my stove revealed that my carrots were almost on fire!  All the water I've put in the cooking pot was completely evaporated... gone... farewell!  I ended up with nice carrots, but the bottom of my cooking pot had suffered quite a bit, as can be seen in the following picture:


Luckily, I'm an optimist.  I never give up.  This stupid cooking pot wasn't going to ruin my day, oh no it wasn't!  Having just lost the plot, I ended up Googling for "How to clean burnt cooking pot" (djee, how did I make that up?), and the Google search resulted in quite some grandma's tips and tricks with soda, coca-cola, vinegar and other kitchen-chemicals... quite overwhelming when you read that for the first time, I must admit.

I stayed focused.  As I didn't have soda nor coca-cola in the house, the chemist in me (seriously, I am joking am i?) decided to go for the vinegar solution:


Having a PhD-level scientist background, I had quite some difficulties believing that this fluid, of which I only knew some culinary properties, was going to solve all my burnt-cooking-pot problems.  But hey,... the optimist in me wanted to give it a try anyway!  I never give up, remember!?  So I started the procedure:
  1. Take the bottle with vinegar from your fridge.
  2. Open bottle.
  3. Pour vinegar into the burnt-like-hell cooking pot.
  4. Put cooking pot aside and pray for the best.
This procedure looked almost too simple to be effective.  How on earth could this clean my cooking pot?  Even the pope has more chance of getting laid than me effectively cleaning out my cooking pot!

But hey, I'm an optimist, so the next day I checked my cooking pot.  While I was affectionately holding it in my hands, carefully checking its burns, I noticed that the layer at the bottom started to move!  I got excited!  It looked as if there was a burnt pancake wandering around in my cooking pot!

Having noticed that, and being in an adventurous mood, I decided to checkout the pancake for myself with my bare hands.  What I noticed then was above all my expectations: I was able to take out the one-hell-of-a-burnt-pancake-of-dirt from my cooking pot, and I was left with an almost clean cooking pot!  Look mom, no scrubbing nor scraping involved!


For the sake of science, this was unbelievable!  Do you notice the pancake in the above picture?  Do you notice how clean the bottom of my cooking pot is?  There is no trickery involved here!  I am not using Photoshop, The Gimp or any other image manipulation software to turn my cooking pot into one hell of a clean cooking pot!  What you see is what I experienced, no more, no less.  Needless to say I was very happy about the way things turned out.  I almost didn't have to rince my cooking pot, I lost some vinegar and above all: I had my cooking pot back with an almost-zero effort!

What I conclude from this is the following:
  1. Being a solo-parenting dad can be challenging at times.
  2. Chemistry in the kitchen is like sex: sure, it may give some practical results, but that's not why we do it (© R. Feynman).
  3. Even when things look bad, really really bad... Never give up!
Yours truly,
Bart

Sunday, December 13, 2015

On faking QObject-derived classes (part 1)

Introduction

After reading Michael Feathers' book Working Effectively with Legacy Code, I recently got interested in techniques for making code more testable.  One of these techniques is Extract Interface, which can be used to replace objects of a certain class with fake versions. While trying to apply this to some legacy code, I stumbled upon a problem.  This post describes that problem and how I solved it.  However, I do have my doubts concerning the elegance of my solution. So therefore: feel free to comment and share alternative solutions!

Starting point

Our starting point is a class derived from QObject:

Because this is a QObject-derived class, it can use methods like setObjectName and objectName, but it can of course also have its own member functions like doFooStuff. Our purpose now is to extract an interface for the Foo class, so we can create a FakeFoo class as a replacement for Foo.

Extracting the interface

Faking the Foo class seems easy at first sight: following Feathers' advice, all I should do is extract a FooInterface and let my Foo and FakeFoo implement it. My first attempt in doing this, looked as follows:

Unfortunately, this resulted in the following compiler errors using g++ 4.9.2:


failed_attempt.cpp: In function ‘int main()’:
failed_attempt.cpp:29:14: error: ‘class FooInterface’ has no member named ‘setObjectName’
     fakeFoo->setObjectName("fake foo");
              ^
failed_attempt.cpp:30:27: error: ‘class FooInterface’ has no member named ‘objectName’
     std::cout << fakeFoo->objectName().toStdString() << std::endl;
                           ^
failed_attempt.cpp:34:14: error: ‘class FooInterface’ has no member named ‘setObjectName’
     realFoo->setObjectName("real foo");
              ^
failed_attempt.cpp:35:27: error: ‘class FooInterface’ has no member named ‘objectName’
     std::cout << realFoo->objectName().toStdString() << std::endl;

Needless to say I was a bit disappointed in realizing that FooInterface indeed did not have a setObjectName or objectName function. Inspired by the section The Case of the Onion Parameter and The Case of the Aliased Parameter in Feathers' book, my current best attempt so far in solving this issue consists of creating a QObjectInterface with these methods and letting FooInterface derive from that:

This works, as is visible in the output of the program:


fake foo
Foo::doFakeFooStuff()
real foo
Foo::doFooStuff()
But my current solution has several drawbacks:
  1. I need to add every QObject member function that I use, to my QObjectInterface.
  2. If I want QObjectInterface and FooInterface to be real interfaces, that forces me to do the implementations of every QObject member function that I use in both my Foo and FakeFoo class. These implementations are just forwardings of method calls to the QObject class. That is quite mechanical, cumbersome and errorprone. I don't like that.
Is this really the best way to go? Or have I overlooked more elegant solutions that don't require me to do all that mechanical, cumbersome and errorprone work?

Conclusion

I did find a way to fake QObject-derived classes, but my solution requires quite some brain-dead QObject-method implementing in the original class and its fake version. I am open for more elegant designs. Please enlighten me! All code in this blog post is available in a public Gist.

Sunday, November 22, 2015

Testing GitHub gists

Occasionally, i day-dream about sharing some random thoughts about certain aspects of software development. An important practical tool needed for this kind of idea-sharing, is being able to nicely embed code-snippets in my blog posts. Googling around for solutions, I came across GitHub gists. This is my first test to embed small pieces of code into my blog posts. If you see a "Hello world!" program below this paragraph, it means my test succeeded...

If you also see a "Hello people!" program below this second paragraph, then it means I'm able to display several different pieces of code into my blog posts.

If you think you know better solutions for embedding code-snippets into Blogger articles, do not hesitate to post a comment!

Wednesday, August 12, 2015

Show your Google Contacts on a map using Google Fusion Tables

Just for the fun of it, I decided to investigate ways to display my Google contacts on a map.  One solution I use already quite a while is the Contacts on map app on my Android smartphone.  But I also want a desktop solution that doesn't require me to enter my Google credentials on a website.  Finding such a solution turned out to be hard, so in the end, I decided to be creative and construct my own solution.  These are the steps I followed.  Google Fusion Tables to the rescue!

Step 1: export your Google contacts

  1. Surf to http://contacts.google.com
  2. In the left menu-bar, under More, find Export and go to the old Google Contacts (because the new Google Contacts doesn't allow you to export your contacts yet).
  3. In the old Google Contacts, select More followed by Export and export your contacts in Outlook CSV format (the Google CSV format didn't work for me):

Step 2: import your CSV file in Google Fusion tables

  1. Surf to http://drive.google.com
  2. Check if you have Google Fusion Tables available under New / More.  If you don't have it yet, install the Google Fusion Tables app.
  3. Create a new Google Fusion Table using New / More / Google Fusion Tables.
  4. Under Import new table use From this computer and select and upload your contacts.csv file.  Use comma as separator character and select UTF-8 character encoding:

Step 3: select the column to use as a location

  1. First, you can remove some unnecessary columns using the Select Columns menu item from the Rows 1 tab.
  2. Then, pick the column you want to use as your location column (e.g. Home Address), and change its type to Location.
  3. Now go to the tab called Map of Home Address and select Home Address as Location column:

  4. Press Begin geocoding and once that's finished, you should see a nice map of all your contacts.

Step 4: finetune

To change several map feature styles and the content of the info window that appears when you click on a contact from the map, go to the tab of the map and select Change map.  It is even possible to display your contacts in a heat map.  My map finally looks like this:


Conclusion

If you keep all your contacts centralized in Google contacts, then visualizing for example their home and work address on a map is rather easy using Google Fusion Tables.  I use these kind of maps a lot when I go somewhere and want to say hi to friends that I haven't seen in a while.

Comments and suggestions on this article are more than welcome!