Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Lesson 11. Creating and Dispatching Even... > Understanding the Benefits of Loose ...

Understanding the Benefits of Loose Coupling

At the end of Lesson 10, “Using DataGroups and Lists,” you were left without a way to add or remove items from the ShoppingCart. With your newly refactored application, the buttons for adding and removing are now inside the ProductItem class; however, the ShoppingCart for the whole application is defined within the ShoppingView class. This means that you can no longer directly call the addItem() and removeItem() methods of the ShoppingCart instance.

Technically, it would be possible to make the shoppingCart property public and still access the ShoppingCart instance from the ProductItem through an expression like this:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial