01.02.2013 Views

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

test for bugs<br />

Figure out what functionality works<br />

You know that Orion’s Orbits was working fine until you integrated the<br />

Mercury Meals library, so let’s focus on that code. The first step is to<br />

find out what’s actually working, and that means tests. Remember, if it’s<br />

not testable, assume it’s broken.<br />

MercuryMeals<br />

uses the singleton<br />

pattern; you<br />

call the static<br />

getInstance()<br />

method to get an<br />

instance, instead<br />

<strong>of</strong> instantiating<br />

the class with the<br />

“new” keyword.<br />

You’ve got two<br />

basic interfaces to<br />

work with, along<br />

with any helper<br />

code that might<br />

be hiding in these<br />

classes.<br />

396 Chapter 11<br />

MercuryMeals<br />

Here’s the main interface to<br />

the Mercury Meals code.<br />

+ getInstance(): MercuryMeals<br />

+ createOrder(): Order<br />

+ submitOrder(order: Order): boolean<br />

+ getMealOption(name: String): MealOption<br />

+ getOrdersThatMatchKeywords(keywords: String[]): Order[]<br />

Order<br />

+ addMealOption(mealOption: MealOption): void<br />

+ addKeyword(keyword: String): void<br />

Remember, we want<br />

to use the flight<br />

number as the<br />

keyword for a meal.<br />

Download at WoweBook.Com<br />

Design note: Naming<br />

a class with your<br />

company’s name is a<br />

lousy idea—Mercury<br />

really was an awful<br />

development shop!

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!