Chapter 13: Composition of Components


Program generators and component-oriented programming go hand in hand. Components and their composition into systems involve some significant problems. Finding just the right component is difficult if software-reuse libraries focus on single components rather than component families. Component families can be developed by taking advantage of design-time and run-time properties. When those are insufficient, generation-time variabilities can be used to design program generators for creating customized components for every occasion. A second major obstacle to component-oriented programming is configuring and connecting components up to create a software system. Connections between components may require sophisticated interface adapters that can take into account such things as parameter conversions, defaults for optional parameters, synchronous and asynchronous connections, and other communication mechanisms. Writing this interface code is tedious and error prone. It should be left to the expertise of a MIL program generator. Finally, building such tools and systems is not difficult. It may be difficult to design a good language or system, but it is not difficult to build the tools using the techniques described in this book.

Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13

Example 13-1: The ShoppingCart Java Bean

Example 13-1: The ShoppingCart Java Bean

public class ShoppingCart implements Basket {
    public Customer getCustomer() { ... };
    public void setCustomer(Customer c) { ... };
    public PriceList getPriceList() { ... };
    public void setPriceList(PriceList p) { ... };
    public TaxDatabase getTaxDatabase() { ... };
    public void setTaxDatabase(TaxDatabase t) { ... };
    public ShippingDatabase getShippingDatabase() { ... };
    public void setShippingDatabase(ShippingDatabase t) { ... };
    public void addItem(Item i) { ... };
    public void removeItem(Item i) { ... };
    public Enumeration getItems() { ... };
    public int getTotalCost() { ... };
    public void addBasketChangeListener(BasketChangeListener l) { ... };
    public void removeBasketChangeListener(BasketChangeListener l) {
        ... };