Game Development Reference
In addition to a reduced working set, the core application will be lightweight and
contain very little business logic. Such a design would make patching and repair-
ing the application really easy because you would just have to patch or repair a
subset of the logic that exists within an external plugin assembly.
As an example, say, for instance, that you have a model viewer application, which
renders 3D models that are structured in your proprietary format. You could have
plugins that add import options for different third-party formats to the file menu.
These import plugins could extend the application to be able to handle different
formats and convert the end result into the proprietary format. If you deploy the
application on a machine where importing is unnecessary, you could simply
remove the external assemblies from the plugins directory.
Controlling an Object Model with Scripts
Perhaps the most powerful extensibility feature of an application is the ability to write
scripts to automate processes and use case flows. Automation can lead to a number
of benefits, including a substantial increase in productivity for tedious and repetitive
tasks. Imagine that you have hundreds of source code files, to which you must
prepend a new copyright comment block. You could do this manually, but it could
take you an hour or more, depending on the project. To save a significant amount of
time, you could write a script in Visual Studio .NET that iterates through the docu-
ments in the solution tree and modifies the text within them automatically.
Another excellent application for integrated script support is in the realm of testing:
functional, performance, and defects. A script could be written to verify that a
particular process or flow works, or a script that determines the elapsed running
time for an intensive calculation, or a script that unit tests the user interface and
business logic looking for errors.
As an example, let's look at the Visual Studio .NET 2005 IDE. One mechanism for
script support is the Command Window, which lets you write a line of code and
instantly execute it. This feature is shown in Figure 43.3.
The Command Window is great for simple evaluations and expressions, but the
functionality of this feature pales in comparison to the power of the macro sup-
port in Visual Studio .NET. As mentioned earlier, almost all Microsoft products
use the same object model, which is probably the most robust object model avail-
able for any application on the market. There are a variety of ways to access this
object model, such as extensions and plugins, but one approach is to script macros
within the IDE. These macros can be saved and reused across projects. Figure 43.4
shows the macro editor in Visual Studio .NET 2005.