Archive for the 'c++' Category

Aim high

Alex Martelli has a great quote on optimization in Python in a Nutshell:
Start by designing, coding, and testing your application in Python, using available extension modules if they save you work. This takes much less time than it would with a classic compiled language. Then benchmark the application to find out if the resulting code […]

The past, present, and future of optimization

I have a relative ("Dan") who used to earn a living optimizing code in the late 70s and early 80s. Around then, a new-fangled high-level language named "C" was starting to catch on, but companies didn't like all the wasted cycles in C programs due to the under-optimized assembly code that their C compilers were […]

Three reasons to avoid private class members

I recently read an interesting post about the need for access control via the private keyword (or an equivalent mechanism) on the CodeThinked blog. The post raises some valid points, but I still think enforced private/protected access is something to be used sparingly at most. Here are three reasons why.
Private members are a pain to […]

How learning Python made me a better C++ programmer

This post on the Raganwald blog spurred me to write about something I've been thinking about for a while: how learning Python has made me a better C++ programmer.
The short answer is, it convinced me to start using the boost libraries (and the Loki library). I'd seen these libraries before, and thought that they looked […]

Classes considered overused

We all love classes. When I write a class, I get a warm and fuzzy feeling, because I know I'm doing OOP.
A class represents a bundle of data and behavior. A classic example is a BankAccount class, which maintains a "balance" state and various methods for manipulating and querying the balance.
This is a great concept. […]

Using late binding from C++

If you're working on Windows, COM is a great way to let Python and C++ collaborate. When you're consuming a COM server written in C++ from Python, the win32com module makes this a snap. Consuming a Python COM server from C++, however, can be a pain, because you have to use late binding.
Note: I've seen […]

Hide your privates, but don’t be a prude

I recently re-read a great post by Alex Martelli on comp.lang.python about OOD in Python. Read the whole thing, it's brilliant.
Alex basically says that most of the encapsulation mantra in languages like C++ and Java is due to (1) remnants of the much derided Waterfall style of software development (BDUF), and (2) deficiencies in the […]

Getting GUI code into a test harness

You've got some legacy C++ code to support. The GUI code has almost no unit tests, but it works.
But now you need to change it. Maybe you need to add a new menu item, or change a generic message box into a custom dialog.
For whatever reason, you need to change your GUI code. It works […]

My kingdom for a decent C++ refactoring tool

These days, I use Python much more than C++ for development, but I've still got a lot of C++ code to maintain. Over the years, the code has gotten crufty in places — mainly GUI and COM automation code, because it's hard to unit test, and thus hard to refactor.
That is, until I read Working […]