Showing posts with label OOP. Show all posts
Showing posts with label OOP. Show all posts

Sunday, August 21, 2011

Spotify/FastDelegate Rabbit Hole


I have become quite the fan of Spotify, but my arse has become increasingly chapped by the "can't play track" errors it's been giving me lately. A quick conversation with my dear friend, Mr. Google, revealed that I should probably empty Spotify's disk cache.

Like a good little user seeking the path to the disk cache, I went to the Spotify "Help" menu, at which point the good little programmer in me was overpowered by curiosity and clicked on the "License" menu item. It turns out that those guys use quite a bit of F/OSS code! By this point, the obsessive-curiosity (which makes me spend 3 hours on Wikipedia following links) had taken over, and I was spittin' new Chrome tabs aster than you can say "OCD much???".

Of the several projects I ended up learning about, "FastDelegate" gave me the most brain-food. Maybe it's because I live a little further away from the metal, maybe it's because I've never actually been paid to write C++ (except for that one time, but I was young & needed the money...), whatever the reason, this head-first submersion into C/C++ function pointers, member function pointers, compiler nuances, and all the blood-n-guts that drove these folks to make "FastDelegate" kicked my brain off its candy-ass treadmill in the Managed Code Fitness Center, and put it on a 40 mile forced march with an Assembly Code rifle in its back!

Oh, as for the Spotify error messages - deleting everything in the disk cache cleared that problem right up!

Friday, June 3, 2011

Virtual Functions

As a combat veteran very experienced professional software developer (server admin, network admin, change management nazi, DBA, architect, glorified typist, coffee lackey, punching bag, and whatever else needs to be done), the overwhelming majority of my career has been built using Microsoft stuff, most notably .NET. The main reason I (and others) have such a hard-on for .NET (or its archetype Java) is the managed runtime. To put it simply - no goofy "pointer arithmetic" for us humans to screw up! But, after all these years of building things inside the warm, loving safety of .NET's fertile womb, I've found myself sneaking closer and closer to the edge,  yearning to get right next to the metal. That's how I ended up finding the article for which this post was created:


Until now, I had never really spent any time mulling over questions like "I wonder whether the implementation of a virtual function gets resolved at compile-time or at run-time?" or "I wonder if there is another human on this planet that gives a shit, much less wants to read a blog post about it?". But hey - today's a new day, and I decided to throw caution to the wind and run with it!

But seriously, that "part 12.5 out of some presumably multi-part C++ thing" up there is pretty friggin' sweet, if you ask me! (I know you didn't, so please STFU...) It explains the real, "under the hood" implementation of virtual functions in such a clear, concise, "plain-speak" manner that I left with a newly gained ability to picture it in my head, almost as a set of 3D puzzle pieces fits together. It is elegant simplicity at its finest. And you know those asshole interview questions about niche subtleties of polymorphism that nobody ever encounters in Real Life? Well, if it involves class foo overriding the virtual function of class bar, you'll never miss it again!

P.S. - I never knew that pretty much all functions in Java are virtual! Weird!?!?