C++ Field Accessors - A Cure for Public Field Phobia

03 Mar 2015

C++ Standard

Recently I was looking for some opinions regarding lack of field accessors in C++ standard. I came across a nice article A Modest Proposal for Curing the Public Field Phobia dated 2001. Since then C++ has matured a lot gaining amazing new features with C++11 and latest C++14 revision, but still some old annoyances like no field accessors remain.

The most often used argument against providing field accessors in C++, it that the language was designed to be verbose and explicit, so it is better to have obj.setX(1) than obj.x = 1, that may let you believe you are accessing some memory directly, while you are not. This leads use however to very obscure code like that:

node.setVisitCount(node.getVisitCount() + 1);

These who are not suffering public field phobia may define visitCount to be public field and use node.visitCount++ . But if it is a dynamic property then C++ does not give you many choices that to use former obscure syntax.

Read the rest of this entry »

Posted in C++, Programming

LiveChat for Mac & iOS behind the scenes

09 Feb 2012

The purpose of this article is to present several technical design concepts implemented and proven to work well for over one year, since the first release of the Mac version of LiveChat operator application.

Back in 2010 when I started implementing the Mac version, the main task was to reach the feature level of the Windows version (developed for several years) as fast as possible, and also to prepare ground for an upcoming iOS version (available now in App Store). At that time I neither had access to the Windows version’s source code, nor was going to reuse any of it. Therefore I have settled the following constraints that yielded the following results (described in detail in following sections):


Read the rest of this entry »

Posted in Objective-C, Programming

Streaming thumbnails smoothly using HTTP in your iPhone app

06 Oct 2010

HTTP Streaming

Network enabled apps such as news aggregators, blogging clients often load lots of small files, such as thumbnails, trough HTTP connection. Usually we expect that such application is: (1) responsive (does not block scrolling while loading), (2) it does load thumbnails almost realtime.

I suppose the first thing everybody tries is calling [UIImage imageWithData:[NSData dataWithContentsOfURL:someURL]]. There is nothing wrong with it, except it make your UI stutter and load images painfully slow. After trying that one may think of using background threads, NSOperationQueue, or something like that, but still any modern web browser loads those images much faster when they are embedded into regular web page than your application. Wonder why?

Read the rest of this entry »

Posted in iOS, Objective-C, Programming

Wanna be 3.x compatible? Not so simple!

08 Jul 2010

iOS 4 icon

So we got the new shiny iOS 4 with the new not-so-shiny SDK 4. Most desirable aspect of using SDK 4 and iOS 4 functions is to be backward compatible with iPhone OS 3.x. This is where you should set your iPhone OS Deployment Target to iPhone OS 3.0 or anything else you want to be compatible with.

Xcode iOS 3 deployment target

This is the official method, and since SDK 4 does NOT come with 3.x headers, the only method to make your app run on 3.x. But it is not so simple, because now in your Xcode you are using iOS 4 API. So how do you know you are not using classes or methods that do not exist in 3.x and putting them into your code will crash your app on 3.x device? You don’t!

Read the rest of this entry »

Posted in iOS, Objective-C, Programming

iPad is a pretty cool docs browser

22 Jun 2010


If you have one, check out http://developer.apple.com/iphone/library/ on it.

Do you like my iPad stand? It is a table easel, paid 25zł (about $10) and it is far more flexible and sexy than all those overpriced dedicated stands. By the way, iPad screen seems to be more blueish than MacBook’s. Both are led backlit, so I wonder why?

Posted in Mac, Programming

Haml + Gettext = automagic translation

13 Apr 2009


I was rather sceptic to Haml once I have first time read about it. But after recently playing a while with it I can frankly express that it is simply outstanding template engine for Ruby. What I miss about Haml is some seamless integration with some i18n framework (gem).

Posted in Programming, Ruby

Opening specified path in Terminal’s new tab

24 Mar 2009

If you ever wondered how to open specified path in new tab of Terminal.app or reuse current one if it is not busy (running a command), here’s a script you may use:

Read the rest of this entry »

Posted in AppleScript, Mac, Programming

Building with MinGW on Mac, oh yeah!

19 Mar 2009


Want to build some small/or not, neat Windows/or Linux application on your Mac? Just use MinGW/Linux GCC cross compiler package from Pierre Molinaro. Those were recently updated to GCC 4.2 and do cross-compile really fast, especially when using make -j2.

It is hard to be Switcher and totally forget/abandon Windows projects, since most of my clients… well almost all of them are on Windows. So since I switched, I am constant user of VMWare Fusion + XP (Win7, Win98) as a guest OS having Visual Studio installed inside. But sometimes if you want to create small cute application for Windows I prefer do it 100% on Mac with TextMate, then just test it on Windows. This is what MinGW cross compiler is perfect for. Not to mention I did Miranda’s MinGW Makefile that successfully builds miranda on Linux/Mac using cross-compiler, so it can be queued for nightly builds on SF.net servers.

Posted in Mac, Programming

No more free lunch, maybe a pie for free?

12 Mar 2009

How to survive computing paradigm shift

We cannot count on free “performance lunch” anymore, but how about at least a pie for free? Do we need to throw all our old source-code into the trash bin and start over again?

Double Core Flow

Certainly, not. We may think of our old software as a zombie of the new multi-core era. Still there is a way to make the zombie walk, even walk faster. Of course we will need to rewrite our code sometime, but we may postpone this nasty need for a while.

Read the rest of this entry »

Posted in Programming

Themed menu’s icons, a complete Vista and XP solution (updated)

12 Jun 2007

Update: Steve King has patched my Vista GDI+ based menus with pure GDI method at Tortoise SVN revision 14191 as described lately by Microsoft. Pure GDI method no longer requires GDI+, which is not present in Premium versions of Vista, maintaining full compatibility with older versions of Windows.

I’m an author of few patches for both Tortoise SVN and Tortoise CVS that makes them display the explorer’s context menu icons nicely on XP and Windows 2000. Both programs are implementing IContextMenu and using QueryContextMenu function to create items of popup menu of explorer. Briefly the called extension must fill menu items with InsertMenuItem using supplied HMENU hmenu parameter.

Posted in Programming, Windows