Home > Articles > Programming

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

This chapter is from the book

1.3 Some Questions

Look again at the list of methods that a client of a customer manager can call.

count : INTEGER
		-- The number of customers the managing object manages
id_active( an_id : CUSTOMER_ID ) : BOOLEAN
		-- Is there a customer with 'an_id'? 
add( a_customer : BASIC_CUSTOMER_DETAILS )
		-- Add 'a_customer' to the set of customers being managed
name_for( an_id : CUSTOMER_ID ) : STRING
		-- What is the name of the customer with 'an_id'?
set_name( an_id : CUSTOMER_ID, a_name : STRING )
		-- Set the name of the customer with 'an_id' to 'a_name'

As you design your client of the customer manager, here are some questions you might want answered.

  • How do I make an id active? By adding a customer with that id?

  • If I add a customer whose details match an existing customer's basic details, what happens?

  • What do I get if I ask for the name of a customer whose id is not active?

  • What happens if I set the name for a customer whose id is not active?

In a component world, the person who developed the component might work for a company on the other side of the globe—and might be sleeping peacefully when you want your questions answered! The component must come with documentation that answers your questions. In the next section, we show how a contract can provide the answers to your questions. In later chapters, we'll see how to write good contracts.

  • + Share This
  • 🔖 Save To Your Account