| « The Glitchy SVN | Testing Done Right » |
C++ has a consistent and fairly simple syntax for defining classes and class members. While this syntax would still look like gibberish to a non-programmer, an entry-level coder could probably understand it after flipping through C++ for Dummies. Kevin Day's predecessor must have been concerned that the former group might be maintaining the system.
Fast forward a few years, and management, not surprisingly, decided that the best folks to maintain their C++ codebase would be, in fact, C++ programmers. And that's where David came in. Faced with the common dilemma understanding a foreign architecture of a foreign product in a foreign business domain, David had at least one bit one thing going for him: a good working knowledge of C++. But since the original designers decided to #define a meta-language in C++, and then use that meta-language to represent all of the key classes, his knowledge hardly came in handy.
#define TAG_DEFINE_INTERFACE( name )\
class name;
#define TAG_BEGIN_INTERFACE(name)\
class name { protected: virtual ~name(){}; \
public:
#define TAG_DERIVE_INTERFACE(name, parent)\
class name : public parent { public:
#define TAG_DERIVE_INTERFACE2(name, parent, parent2)\
class name : public parent , public parent2\
{ public:
#define TAG_END_INTERFACE()\
};
#define TAG_DECLARE_FUNCTION(func)\
virtual func = 0;
#define TAG_DECLARE_SETGET_FUNCTION(returntype, func)\
TAG_DECLARE_FUNCTION( returntype Get ## func() )\
TAG_DECLARE_FUNCTION( void Set ## func(returntype) )
It's worth pointing out that using these macros broke Visual Studio's "Go To Declaration/Definition" function, which is also useful when one is trying to get to grips with the code.
|
I particularly like the way that TAG_DEFINE_INTERFACE **declares** a class without defining it.
This is the result of someone trying to find a clever way to prevent people from creating mixed interface/implementation classes. That is, accidentally (or otherwise) adding a non-purevirtual function, or, godforbid, a variable to an interface class. The intelligent way (note that there is a big difference between intelligent and clever!) is called a code review, but to be effective it requires people to be intelligent about how they review things. In the absence of that, the sole virtue of this is that it makes it more obvious to a reviewer that you have broken the rules of the game - a "correctly" defined interface consists entirely of TAG_... macro invokations (and some comments, I'd hope). The correct solution, of course, is to hire better quality developers, but that will never catch on. |
| « The Glitchy SVN | Testing Done Right » |