November 1999
Intermediate to advanced
240 pages
5h 22m
English
Difficulty: 5
How are your OO design skills? This Item illustrates a common class design mistake that still catches many programmers.
A networking application has two kinds of communications sessions, each with its own message protocol. The two protocols have similarities (some computations and even some messages are the same), so the programmer has come up with the following design to encapsulate the common computations and messages in a BasicProtocol class.
class BasicProtocol /* : possible base classes */ { public: BasicProtocol(); virtual ~BasicProtocol(); bool BasicMsgA( /*...*/ ); bool BasicMsgB( /*...*/ ); bool BasicMsgC( /*...*/ ); }; class Protocol1 : public BasicProtocol { public: Protocol1(); ~Protocol1(); ...Read now
Unlock full access