Home > Articles > Programming > Visual Basic

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Test Application Architecture

A prototype can test the application's preliminary architecture. While building the prototype, you can implement the overall framework that you think you will need to build the final application. If it doesn't work for the prototype, it probably won't work for the final application, either.

Two of the most common application design strategies are object-oriented design and stepwise refinement. The following two sections explain how a prototype can help you refine a project design using these two approaches.

Object-Oriented Design

In an object-oriented architecture, you begin by identifying the programming objects that make up the system. You determine how those objects interact and what sorts of features they must have to do their work individually and as a group.

For example, a point-of-sale system might have objects representing customers, orders, order items, and inventory items. These objects have properties and methods for dealing with their own abstract data. The Customer object contains information about a customer: name, billing address, shipping address, account number, account balance, and so on. The objects also must know how to work together. The Customer object needs to know how to create a new Order object representing an order created by that customer. The Order object needs to know how to make OrderItem objects representing the items in the customer's order. One of these objects needs to know how to combine all the OrderItems to produce a bill for the customer.

Other objects might deal with controlling the application rather than the domain. These objects might include User, Privilege, Form, Printer, and Report objects.

In this kind of object-oriented architecture, the prototype should implement the most important objects. In this case, those would probably be the Customer, Order, and OrderItem classes. The prototype should define the main interactions among those objects and provide enough detail that it can display a reasonable imitation of the final application.

Some objects may provide only enough features to let the prototype work. When a user wants to create a new order for a customer, the new Order object might contain exactly four OrderItems. The final application would let the user add and remove OrderItems as needed, but the prototype just needs to show what OrderItems look like. The prototype may even omit some less important objects. In this example, the prototype might not provide real user name and password checking. It also might not verify permissions before allowing the user to generate reports and view certain screens.

A prototype should definitely include any objects that you don't understand completely. If you plan to interact with a data acquisition system and you have not done so before, include the data acquisition classes in the prototype. The prototype gives you a chance to test things that you don't understand in miniature before you try to implement them in the full-blown application. If you don't investigate these issues now in the prototype, you will have to handle them later when changing the system's design will be much harder.

As you build the prototype, you will learn more about the interactions among the objects. You may discover new features that an object should provide. You may find that some objects are unnecessary or that you need a new type of object that you didn't anticipate. Building the prototype will help you finalize your object architecture.

If you start making too many changes to the original design, you should probably step back and reevaluate it. You will probably get a better result if you rewrite the design from scratch rather than incrementally patching it up to make the prototype work. When you have revised the design, you can start a new prototype.

When you have finished building the prototype, you should have the object model fairly well tested, at least at a high level. If the prototype uses at least partial implementations of the system's most important classes, then your design is probably on track.

Stepwise Refinement

In the stepwise refinement development approach, you begin with a general statement of the program's design. For a point-of-sale system, this might be something like the following:

    Store records describing customers, orders, and order items. Allow the user to create a new order and generate a bill automatically. Provide lots of reports.

You then add more detail to this description to explain more about how the tasks will be accomplished. For example, you might mention that users need to log on with user names and passwords, and that you will store data in a relational database.

When the system's description becomes too unwieldy, you group related tasks and break them into subsystems. You then add more detail to the descriptions of the subsystems. You continue this process—adding more detail and breaking the pieces of the system into smaller pieces—until you reach some level where you think you understand the complete solution. At this point, you could start writing code to handle the smallest tasks. You could then combine them to solve higher-level problems, and so on until you had completed the entire application.

When you build a prototype, you need to decide which of the tasks you have defined should be included in the prototype. Usually those tasks include a large part of the application's user interface. That lets customers understand how they will interact with the program. Building menus, buttons, and forms is relatively easy in Visual Basic, so including a lot of user interface in the prototype is not too difficult. This also lets you test any interface elements that are not part of the standard Visual Basic toolkit. For example, if you will be using a new ActiveX control that you just bought, you can try it out in the prototype to see if it can do everything you need. The user interface also provides a starting point for demonstrating deeper parts of the application. Pushing a button can launch code that tests pieces of the system that you need to study in greater detail.

You should include pieces of the design that you don't fully understand in the prototype. For example, if the final program must update a database on a Web server, the prototype should demonstrate that capability. The prototype need not implement every detail of this operation, but it should prove to you that you could accomplish the task. In this case, the prototype might connect to a database on a Web server and update a specific record. If you can do that much in the prototype, you will have some confidence that you can update records more generally in the final application.

As you build the prototype, you will probably discover new tools that you need to build that you hadn't thought of before. You may also find that you don't need other utilities that you thought would be necessary. Building the prototype will help you finalize your project architecture.

If you start making too many changes to the original design, you should probably step back and reevaluate it. You will probably get a better result if you rebuild the design from scratch rather than incrementally patching it up to make the prototype work. When you have revised the design, you can start a new prototype.

When you have finished building the prototype, you should have the overall architecture fairly well tested. If the prototype demonstrates basic features from each of the program's major subsystems, then your design is probably on track.

  • + Share This
  • 🔖 Save To Your Account