14+-+Interfaces+and+Invariants

14+-+Interfaces+and+Invariants - 5/25/2009 Getting access...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
5/25/2009 1 Interfaces and Invariant Ve 280 Programming and Introductory Data Structures Interfaces and Invariants 1 Getting access to our CTools site 1. Create a Friend Account (if you don’t already have umich access): http://www.itd.umich.edu/itcsdocs/s4316/ (follow the instructions) 2. Once your account is created, go to the link below and log in: https://ctools.umich.edu/portal 3O l d i t t h Mbh i ” li k i th l ft 2 3. Once logged in, go to the Membership link in the left menu. 4. In the Membership screen, click on “Joinable Sites”. 5. In the “Joinable Sites” screen, search for “Ve280-Su09-Session1”. 6. Under the “Ve280-Su09-Session1” Worksite, click “Join”. 7. “Ve280-Su09-Session1” should now appear as a tab at the top of your Ctools screen. Click on the tab to go to our site. It is very similar to Sakai. ADTs Recall y Recall the two main advantages of an ADT: 1. Information hiding : we don't need to know the details of how the object is represented, nor do we need to know how the operations on those objects are implemented. 3 2. Encapsulation : the objects and their operations are defined in the same place; the ADT combines both data and operation in one entity. Recall y To the caller, an ADT is only an interface. y Here are two definitions: y Good Definition : The contract for using things of this type. y Better Definition : The set of assumptions that each programmer needs to make about the other's code in order to 4 programmer needs to make about the other s code in order to demonstrate the correctness of their own code. y Once you have an interface, you can pick from among many possible implementations as long as you satisfy the (implied) contract. Interfaces Separating out the details y The class mechanism, as we've used it so far, has one shortcoming: y It co-mingles details of the implementation with the definition of the interface . 5 y Recall that the implementation of a class includes: 1. Data members 2. Method implementations y The method implementations can be written separately from the class definition and usually are. Interfaces Separating out the details y For example, if we were really building an IntSet , we'd split it across two files: y intset.h – the class IntSet {. ..} definition y intset.cpp – the implementation of each method y Unfortunately, the data members still must be part of the class 6 definition. y Since any programmer using an IntSet must see that definition, those programmers know something about the implementation. y However, in a well-designed class, any implementation-specific bits must be either private or (less preferably) protected members. So, client code can't touch those objects.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
5/25/2009 2 Interfaces Separating out the details y Having data objects in the definition has two undesirable effects: 1.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/26/2009 for the course EECS 280 taught by Professor Jeff during the Summer '09 term at University of Michigan-Dearborn.

Page1 / 6

14+-+Interfaces+and+Invariants - 5/25/2009 Getting access...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online