Aggregation, static variables, Model/View

Aggregation means that one class has one or more objects of another class. This is called a "has-a" relationship between classes.

We can represent this relationship with a UML diagram. UML stands for Unified Modeling Language.

We use a rectangle for each class. We use a line with an open diamond to designate the "has-a" relationship.

In the Bakery example, the BakeryGUI has a Bakery and the Bakery has a Cake:



What is a static variable?

Model / View

What are some ways a real bakery could sell cakes to its customers?


The Bakery Program

The Bakery class provides a "model" of a bakery. The BakeryGUI class provides a "view" of (or interface to) the Bakery. The BakeryGUI sends "messages" to the Bakery object and the Bakery sends "messages" to the Cake objects. The Cake objects send "messages" back to the Bakery and the Bakery sends "messages" back to the BakeryGUI.

The School Supply Store Program

The SupplyStore class provides a "model" of a school supply store. The SupplyStoreGUI class provides a "view" of (or interface to the SupplyStore). Messages are also sent between the SupplyStore object and the SupplyStoreGUI and between the SupplyStore and its Items.