1 / 8

BTS530: Major Project Planning and Design

BTS530: Major Project Planning and Design. Patterns for a Persistence Framework References and Material From: Applying UML and Patterns, 3 rd Edition, chapter 38. Agenda. Pattern: Cache Management Pattern: State Pattern: Virtual Proxy (for lazy materialization). Pattern: Cache Management.

Download Presentation

BTS530: Major Project Planning and Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BTS530: Major Project Planning and Design Patterns for a Persistence Framework References and Material From: Applying UML and Patterns, 3rd Edition, chapter 38

  2. Agenda • Pattern: Cache Management • Pattern: State • Pattern: Virtual Proxy (for lazy materialization)

  3. Pattern: Cache Management • Issue: • Want to maintain materialized objects in a local cache to improve performance (materialization can be slow) and support transaction mgmt operations such as commit.

  4. Pattern: Cache Management • Solution: Cache Management Pattern • Make the database mappers responsible for maintaining its cache. If a different mapper is used for each class, each mapper can maintain its own cache. • Materialized objects are placed in the cache with OID as key. Mapper searches cache first to avoid unnecessary materializations.

  5. Pattern: State • Problem: is there an alternative to conditional logic when an object’s behaviour is dependent on its state. • Solution: State Pattern (GoF) • create state classes for each state (OldDirty, OldClean, etc.), implementing a common interface. • delegate state-dependent operations from the context object to its current state object. • ensure context object always points to a state object reflecting its current state.

  6. Lazy Materialization • Sometimes its best to defer materialization of an object. • e.g. ProductDescription references Manufacturer but only rarely does the latter need to be materialized. • this deferred materialization is known as lazy materialization.

  7. Lazy Materialization • Pattern: Virtual Proxy (GoF) • a “lightweight” version of the “real” object that may or may not be materialized. • the proxy only materializes the real object when it is required.

  8. Fig. 38.16, p. 649

More Related