1 / 29

Promotion

Promotion. Promotion. Promotion is a structuring technique that may be used whenever the state of a system contains multiple, indexed instances of the same component.

demont
Download Presentation

Promotion

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. Promotion

  2. Promotion • Promotion is a structuring technique that may be used whenever the state of a system contains multiple, indexed instances of the same component. • It is most useful when several operations are possible upon the component, and their effect is independent of the index: that is, their effect is the same for each instance.

  3. Example1 • The state of a game of trivial pursuit might be described using the following pair of schemas:

  4. Example1

  5. Example1 • The change in state associated with a single player answering a scoring question correctly could be described by:

  6. Example1 • The change in local state - in the individual player's score - could be described by

  7. Example1 • The following mixed operation identifies a particular local score; one of the copies indexed by score:

  8. Example1 • The following operation describes the change in global state that accompanies such a correct answer: • Removing the extra names from the declaration, we obtain a global operation schema:

  9. Promotion Schema • If Local describes a copy of the local state and Global describes a copy of the global state, then a promotion schema Promote will contain decorated and undecorated copies of both Local and Global. • If LocalOperation contains decorated and undecorated copies of Local, then we may promote LocalOperation to the global operation

  10. Example2

  11. Example2

  12. Example2 • Each mailbox is a binding:

  13. Example2 • A local operation:

  14. Example2 • A promotion schema:

  15. Example2 • A global operation:

  16. Example2 • A global operation (without promotion):

  17. Example3

  18. Example3

  19. Example3 A local operation:

  20. Example3

  21. Example • We wish to describe a library of musical recordings on tape or compact disc. We shall call this system as AudioLib. We want to attach a loan category to each recording copy and we want to maintain a record of the date on which the copy was loaned out.

  22. Example • For this system the set Recording is defined by a schema so that the members of this set have a particular structure Recording cat : Category loans : seq Date rec : RecordingDetails • Date is a given set and RecordingDetails is either a given set or a schema type defined elseware • Two loan categories: Category ::= Loanable | Restricted

  23. Example • A given set of identifiers used to identify uniquely each distinct physical tape or compact disc in AudioLib stock [RecId]

  24. Example • We define the abstract state for the AudioLib system AudioLib stock : RecId ↛Recording out : RecId ↛Listener listeners : Listener dom out  dom stock ran out  listeners  r : dom out  (stock r).cat = Loanable

  25. Example • The predicate part of this schema says that: - only items of stock can be out on loan - loans can only be made to registered listeners - items out on loan must be loanable and not restricted to the library

  26. Example • We define an operation to change the loan category of a Recording ChangeCategory Recording newcat? : Category report! : Report cat ≠ newcat?  (report! = Ok  cat’ = newcat?) cat = newcat?  (report! = NoChange  cat’ = cat?) loans’ = loans rec’ = rec

  27. Example • To promote operations on individual Recordings to be operations on the AudioLib abstract state, we factored using promotion; we define a promotion schema Promote AudioLib Recording rcid? : RecId rcid?  dom stock Recording = stock rcid? stock’ = stock  {rcid? ↦ Recording’}

  28. Example • The constraint Recording = stock rcid? ensures that Recording concerned is the one corresponding to stock rcid? • The constraint stock’ = stock  {rcid? ↦ Recording’} ensures that stock is unchanged except that rcid? Is now associated with the modified Recording • we could define an operation ChangeRecordingCategas: ChangeRecordingCateg ≙  Recording  ChangeCategory Promote

More Related