From the course: Java Design Patterns: Structural

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Challenge: The Proxy pattern

Challenge: The Proxy pattern - Java Tutorial

From the course: Java Design Patterns: Structural

Start my 1-month free trial

Challenge: The Proxy pattern

(upbeat techno music) - [Instructor] Let's have a look at our next challenge. This one is to refactor an app for viewing a store's inventory of items, so this app has a class called item which represents different types of item you could buy in a store. It has fields for name, price, and quantity. Next there's an interface called inventory, which has a single method called get inventory which returns an array list of items. There could be different concrete implementations of inventory for all the different types of store. In this example, we've just got one concrete implementation called superstore inventory. In the constructor, lots of items you might find in a superstore are added to the array list of items. In a commercial app, this information might be stored in a database and instead of adding to and retrieving the items from an array list, there might be some expensive calls to connect to a database here. To keep…

Contents