CIS-260 Home http://www.c-jump.com/bcc/

Distinguishing Interface and Implementation


  1. Distinguishing Interface and Implementation
  2. Difference between interface and implementation
  3. Programming and Code Reuse
  4. Two parts of the proper class design
  5. Implementation and Interface Considerations
  6. Controlling Object Creation
  7. Database Reader class example
  8. Abstract Interface

1. Distinguishing Interface and Implementation


2. Difference between interface and implementation


3. Programming and Code Reuse


4. Two parts of the proper class design


5. Implementation and Interface Considerations


6. Controlling Object Creation


  • 
    public class Planet
    {
        int distance;   // distance from star
        int satellites; // # of satellites
        double mass;    // the mass
    
        public Planet() // default constructor
        {
            this.distance = 0;
            this.satellites = 0;
            this.mass = 0;
        }
    
    
  • 
    public class GasGiant extends Planet
    {
        public GasGiant()
        {
            // Explicit call to
            // base constructor:
            super();
        }
    }
    
    
  • 
        public Planet(int distance, int satellites, double mass)
        {
            this.distance = distance;
            this.satellites = satellites;
            this.mass = mass;
        }
    }
    
    

7. Database Reader class example


  • First, we gather user requirements.

  • From requirements we create our class diagram.

  • Each plus sign in front of operation proclaims that the operation is public.

    DataBaseReader class diagram

8. Abstract Interface