1 / 15

Data Design

Data Design. SIM5104. Principles of data design. Abstract objects of the specification have to be represented by data structures Two modes of data design: Direct Implementer chooses data structures of the targeted programming languages Indirect

artan
Download Presentation

Data 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. Data Design SIM5104

  2. Principles of data design • Abstract objects of the specification have to be represented by data structures • Two modes of data design: • Direct • Implementer chooses data structures of the targeted programming languages • Indirect • Implementer chooses abstract data types such as files, trees etc.

  3. Abstract view : user’s view • example Test operation Enquire operation Leave operation Enrolled set Tested set Enrolled operation

  4. Concrete view: implementer’s view array tctr ectr is enrolled counter tctr is test counter ectr

  5. Concrete state data Class enrolled, tested : ℙ Student #enrolled ≤ size tested ⊆ enrolled

  6. Concrete state data DClass sarray : (1..size) → Student ectr : 0..size tctr : 0..size tctr ≤ ectr ∀i, j : 1..ectr | i ≠ j • sarray i ≠ sarray j

  7. Forward simulation • To bring together the abstract state and the concrete state Dsim Class DClass enrolled = {i: 1..ectr • sarray i} tested = {i:1..tctr • sarray i}

  8. Concrete Initial State DInit DClass’ ectr’ = ∅

  9. Enrolling a student: abstract EnrolOk ∆Class s? : Student r! : Response s? ∉ enrolled #enrolled < size enrolled’ = enrolled ∪ {s?} tested’ = tested r! = success

  10. Enrolling a student: concrete DEnrolOk ∆DClass s? : Student r! : Response ∀i : 1..ectr • sarray i ≠ s? ectr < size tctr’ = tctr ectr’ = ectr + 1 sarray’ = sarray ⊕ {ectr’ ↦ s?} r! = success

  11. Corresponding predicates Abstract concrete ∀i : 1..ectr • sarray i ≠ s? ectr < size ectr’ = ectr + 1 tctr’ = tctr sarray’ = sarray ⊕ {ectr’ ↦ s?} r! = success s? ∉ enrolled #enrolled < size enrolled’ = enrolled ∪ {s?} tested’ = tested r! = success

  12. Other related schemas DNoRoom ΞDClass r! : Response ectr = size r! = noroom DAlreadyEnrolled ΞDClass s?: Student r! : Response ∃i: 1.. ectr • sarray i = s? r! = alreadyenrolled DEnrol ≙ DEnrolOk ⋁ DNoRoom ⋁ DAlreadyEnrolled

  13. Using Linked Lists next data next data next data head next data [Pointer, Data] Given set for pointer and the kind of data stored In the blocks in the linked list | nil_pointer : Pointer A pointer does not point at anything Block next : Pointer data : Data Type of blocks in the list

  14. Linking of blocks : Queue Queue head : Pointer block_at : Pointer ↛ Block pointers : seq Pointer nil_pointer ∉ dom block_at ran pointers = dom block_at #pointers = #ran pointers pointers = < > ⇔ head = nil_pointer ( pointers ≠ < > ⇒ ( head pointers = head ⋀ (block_at (last pointers)).next = nil_pointer ⋀ (∀i: 1..(#pointers – 1) • (block_at(pointers i)).next = pointers(i + 1)))) Starting pointer Relation between pointers and the block they address Sequence of pointer to chain block together

  15. Add to head AddToHead ∆Queue Block new_pointer? : Pointer data? : Data new_pointer? ∉ dom block_at data = data? pointers’ = <new_pointer> ^ pointers block_at’ = block_at ⊕ {new_pointer? ↦ θBlock}

More Related