Microsoft states that the OTB purpose is:
- Teaching object-oriented programming concepts without going into language syntax
- Providing a lightweight testing tool designed for academic and hobbyist programmers to use on small and simple projects
- Shortening the write-debug-rewrite loop
- Testing simple classes and their methods
- Discovering the behavior of a library API quickly
OTB operations are acessible from the "Class View" and the "Class Designer". Most of the times we don't have a class diagram to interact with the classes, so I end up using Class View most of the times.
Here's a practical example. Say you have 3 classes: Message, MessageProcessor and ProcessedData. The MessageProcessor handles a Message instance to create a ProcessedData instance. If you suspect the MessageProcessor as a bug and wish to debug it, you just need to create a Message instance, a MessageProcessor instance and invoke the method that handlers the Message. Depending on what you wish to debug, you may just inspect the output (a ProcessedData instance) or you may set a few breakpoints in the MessageProcessor class to better diagnose what's happening. Here's a few screenshots that show how this can be done in the OTB.
|Right-click the target class in Class View and Choose "Create Instance". In this case there is a single constructor, but there could be other overloaded constructors. Also note that this menu also allows you to invoke static methods of this class|
|Whenever you create a new instance a dialog shows up, allowing you to define the name of the create instance. If the constructor had parameters, it would also request you to enter the constructor parameters|
|The OTB after creating a Message and a MessageProcessor instance. Invoking the ProcessMessage method in the MessageProcessor instance|
|When the method has a return value you're allowed to save and name the object|
|The OTB allows you to inspect these objects by hovering|
|You can also inspect/use the OTB locals in the Immediate window by using the name you've previously specified|