Fog Creek Software
Discussion Board

C, T or I?

C = Class
T = Type
I = Interface

I've seen these three letters prefix the names of classes.  Now what the heck is the difference?  I know MS uses C in the MFC classes and Borland used T in the ObjectWindows? classes and 'I' is used sometimes interchangeably with C and T.  I mean who ever heard of CUnknown? 

Shouldn't 'I' be used for true interfaces?  Now that begs the question of what is a true interface?  Don't all classes implement an interface?

So what's the deal with C, T and I?

Thursday, August 5, 2004

In our C++ work, C is for a class implementation, T is for a template class, and I is for an interface, either defined by COM or as a C++ class with all pure virtual functions.

Thursday, August 5, 2004

> Now that begs the question of what is a true interface?

A pure abstract base class: all methods are public and pure virtual (no implementation), and no member data.

Christopher Wells
Thursday, August 5, 2004

I used to do that business with prefixing symbol names with short mnemonics too, but now I feel like any information like that ought to be obvious from the context (and where it can't be, it's a failure of the language).

Take joel's "default.asp" script for example.  If I wrote it, I'd refer to those variables as "PostParent" and "Headline", although I'd be perfectly happy to let an intermediate layer tack on the "ix" and "s" prefixes at lower levels to ensure type consistency (because obviously there are fundamental type constraints -- like what types of values you can store in a database column).  It sounds like a trivial issue but when you've got a ton of (incompressible) code, removing details aids comprehension.

Thursday, August 5, 2004

I have used the class "CUnknown". 

CUnknown is the C++ Class that impliments the abstract class (aka Interface) "IUnknown" or more often "INondelegatingUnknown"

Read the book "Inside COM" by Dale Rogerson for more.
Inspect the DirectShow SDK source/header files for more.

Thursday, August 5, 2004

So what do you use CUnknown for?  As much fun as calling AddRef and Release all day long is, I'd rather be doing something else ... ;-)

Michael Kale
Thursday, August 5, 2004

None. The fact that it begins with a capital letter is a giveaway.

Thursday, August 5, 2004


This class should be called View.

Thursday, August 5, 2004

No I,C or T's.

I used them extensively in C++

But in Java, there is much less need to so since they are keywords in the language.

Also, given the editor (IDEAJ), there is a lot of support for seeing the hierarchy, parents, implementations etc.

As for the names being already taken, it's very well possible to put the interface in its own package.

Friday, August 6, 2004

I only use I to represent abstract base classes.  I as well much prefer java's interfaces to C++'s abstract base classes.

christopher (
Friday, August 6, 2004

*  Recent Topics

*  Fog Creek Home