Project Stage B - Data Structures

You can "discover" data items and groups by looking at the nouns in your user-stories.  Consider the Fair Trade example:

Here is the same "story" with all the nouns highlighted:

You won't need variables for every noun, but the nouns give you some ideas for variables:

If you were actually writing a project for this scenario, you would have already done Stage A.  But you can still reflect on some ideas:

Looking at the thoughts above, we see that each item has a name and connections/relationships to other data items.

Enter OOP

In OOP, we try to group together connected ideas.  Compare an old-fashioned program to an OOP program:

 

Traditional Approach

OOP

String organization = "Starbucks";
String password = "starry night";
String supplier = "Coffee Growers Union";
String country = "Honduras";
String product = "coffee";
double price = 3.50;

// ******************************

// What if the supplier has a list of
// various products that they sell?

// What if we want a list of all the suppliers
// who sell coffee?

// Traditional programming methods
// make it difficult to create lists.

class Organization
{  String name;
    String password;
}

class Supplier
{ String name;
   String country;
   Product product;
}

class Product
{ String name;
   double price;
}

//***  Now making lists is easy *****************

Organization[] orgs = new Organization[1000];

Supplier[]  sups = new Supplier[1000];

//*** We should rewrite the Supplier class *********

class Supplier
{ String name;
   String country;
   Product[] product = new Product[1000];
}

//*** Not all lists should be 1000 items,
//*** but that will probably work for most projects.

The OOP version requires some extra code ( the class command ), but is a lot more flexible and saves work in the long run.

Discovering Data for Your Project

Look back at the user-stories and sample data you collected in stage A or your project.  Then do a similar analysis to the one above.  Make sure you find examples for all the following :