Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a class System, which uses a bunch of other classes, to achieve a complex

ID: 658923 • Letter: I

Question

I have a class System, which uses a bunch of other classes, to achieve a complex signal processing.

In debugging System, one needs to observe the output signal for patterns. This is not achievable by a debugger, because of the large number of samples going through.

However, if certain parts of System can be isolated and hooked to the environment, instead of System, simpler transformations are performed on the signal and it is easier to see if those individual parts are working.

This is in addition to tests to each class, that comprises System. Once integrated, the otherwise working components could exhibit bugs. Furthermore, testing 2 or 3 of those chained together is another approach to understanding why System is not performing correctly.

Consequently, methods were introduced in System to hook various inters from/to the environment. Those methods are not needed to a final user of the class, but also cannot be removed.

How can those methods be arranged / named / mixed-in so that the interface is clear to an end user of the class, while still providing the debugging behavior hacks, needed for figuring out bugs?

Explanation / Answer

My first reaction is that you should examine the possibility to use e.g. event tracing or logging in order to observe the system's behavior instead of having explicit methods in your class. Existing frameworks often gives you the possibility to modify levels of output dynamically, i.e. at run time, with overhead that is acceptable for most environments.

That being said, if this is really the way you want to go, maybe something like this would be a bit cleaner (pseudo code, not C++):

interface IDebugInfo
{
int SomeDebugCounter();
}

interface IDebugInfoProvider
{
IDebugInfo GetDebugInfo();
}

class System
: IDebugInfoProvider
{
class SystemDebugInfo : IDebugInfo
{}

IDebugInfo GetDebugInfo()
{
return new SystemDebugInfo(...);
}
}