DVD Rental
This application implements a basic DVD rental application.
- Members are identified by name
- DVD Copies are identified by Serial Number(sn)
- Code is more or less modularised by class
- (Nearly) all state is held as Events in an Eventlist per class (Member, DVD and Hire)
- State is computed on demand from the Event list - for example whether a DVD is on hire
or in stock is determined by a predicate over the eventlist for that DVD.
Limitations
These are omitted to keep the code small to illustrate the stateless approach but could be added using eXist functionality.
- No authorisation
- UI generated in XQuery
- No sessions
Issues
- Much of the code is UI, and much of that is a controller for the UI, displaying
different information and prompts depending on the state of the interaction.
This might be cleaner done through XSLT, clearer still with some descriptor of the interaction in a declarative form such as XForms. But the XQuery is as declarative
as I can make it within the limitations of sequencing the parts of the form and the final updates to the events.
- Would be good to do some performance testing, with volume and indexes.
- Events are held in separate Event Lists. Would a global event list be preferable?
- Events are entry-ordered. Eventlists could be explicitly order by date if required but slower
- Sn and name could be changed to attributes to indicate their role as primary keys.
Code
- Base date files and schema generatd by trang:
- XQuery Modules
- XQuery Scripts
To do
- Payments
- Better handling of the two level chargeband - defined at both Title and copy level
- New DVD and DVD actions - Band change, Withdrawn
- New Member actions - terminate
- New Views - history of rentals for a DVD using Reflection on the schema.
- Dvd and DvdCopy variable naming needs cleanup