1 / 14

ADT

ADT. ITEC 320 Lecture 22. Review. Generic lists Ada compilation workout Recursive algorithms What would a recursive copy look like? Project 4 is up (Dr. Okie’s site) Due next Tuesday at 10PM. Outline. ADTs What are they ? Why should we study them? What are they good for?.

Download Presentation

ADT

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. ADT ITEC 320 Lecture 22

  2. Review • Generic lists • Ada compilation workout • Recursive algorithms • What would a recursive copy look like? • Project 4 is up (Dr. Okie’s site) • Due next Tuesday at 10PM

  3. Outline • ADTs • What are they ? • Why should we study them? • What are they good for?

  4. Definition • A type in which • What the operations of the type are is public • How it is implemented is private • Abstract because irrelevant details are ignored • i.e. how it is implemented is ignored • Benefits / dangers of how something is implemented

  5. Place • Top down software design • Decompose into smaller problems • Bottom up software design • Have tool, use tool • Design new tool if not in toolbelt

  6. Examples package BigNumPkg is type BigNum is private; Zero : constant BigNum; One : constant BigNum; BigNumOverFlow: exception; function toString(X: BigNum) return String; function "<" (X, Y : BigNum) return Boolean; function ">" (X, Y : BigNum) return Boolean; function "<=" (X, Y : BigNum) return Boolean; function ">=" (X, Y : BigNum) return Boolean; function "+" (X, Y : BigNum) return BigNum; function "*" (X, Y : BigNum) return BigNum; procedure Get (Item : out BigNum); procedure Put (Item : BigNum; Width : Natural := 1); private Size : constant Positive := 50; type BigNum is array(0..Size-1) of Integer; end BigNumPkg;

  7. Design a • Stack • Queue • How would you take a doubly linked list and use it to make a stack / queue?

  8. Support • Ada • Package • Java / C++ • Classes (Java packages != Ada packages) • C • What do you think? • Others • modules

  9. Defining • Values it holds • Set of operations it performs • Declaration • Allocation • Modification • Querying, Modifying, Combination, conversion, input/output • Iteration

  10. Iterators • What does the term mean to you? • Traversal versus access + printing Tree t = new Tree(); // Add some elements here Iterator i = t.getIterator(); while i.hasNext() S.o.p(i.next());

  11. Why? • Simplicity • High level operational thinking • Abstractions on top of abstractions • Reliability • Flexibility • Independence

  12. Design principle • Parnas Principle • Maximize cohesion • Minimize Coupling • Why?

  13. Question • What should make up a standard library of ADT’s?

  14. Summary • ADTs

More Related