Fundamentals of Software Development 1Slide 1 Why have interfaces? A Java interface is the “face” that one class shows othersA Java interface is the “face”

Slides:



Advertisements
Similar presentations
CLASS INHERITANCE Class inheritance is about inheriting/deriving properties from another class. When inheriting a class you are inheriting the attributes.
Advertisements

Template. 2 Using templates, it is possible to create generic functions and classes. In a generic function or class, the type of data upon which the function.
Interfaces CSC 171 FALL 2004 LECTURE 14. Project 1 review public class Rational { private int numerator, denominator; public Rational(int numerator, int.
Object Oriented Programming
Fundamentals of Software Development 1Slide 1 Recap: Constructors, the new operator and the this object Three ideas:Three ideas: –How to write a constructor.
Fundamentals of Software Development 1Slide 1 Review: Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote.
Unified Modeling Language
Inheritance Inheritance Reserved word protected Reserved word super
ITEC200 Week01 Introduction to Software Design.
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
Fundamentals of Software Development 1Slide 1 Today’s Summary UML class diagrams – –Why classes are important – –UML class diagrams – relationships – –UML.
Interfaces. Lecture Objectives To learn about interfaces To be able to convert between class and interface references To appreciate how interfaces can.
Fundamentals of Software Development 1Slide 1 One class can describe many different instancesOne class can describe many different instances –Two NameDroppers,
Fundamentals of Software Development 1Slide 1 Interfaces Outline:Outline: –Generic interface versus Java interface –What a (Java) interface is: Its syntaxIts.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Fundamentals of Software Development 1Slide 1 Method invocation versus definition To define (write) a method means to write its codeTo define (write) a.
Java 212: Interfaces Intro to UML Diagrams. UML Class Diagram: class Rectangle +/- refers to visibility Color coding is not part of the UML diagram.
Fundamentals of Software Development 1Slide 1 Methods: Defining, Invoking, Executing “There is a difference between knowing the path and walking the path.”
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
Interfaces besides classes, Java recognizes another type, an interface interface is used to completely shield off all implementation from the programmer.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
Fundamentals of Software Development 1Slide 1 Outline Designing a computational community for WordGamesDesigning a computational community for WordGames.
Copyright 2008 by Pearson Education Building Java Programs Chapter 9 Lecture 9-4: Interfaces reading: self-check: exercises: #11.
Java Implementation Software Construction Lecture 6.
Object Oriented Software Development
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Java Classes, Interfaces, and Types 1.
Fundamentals of Software Development 1Slide 1 Why start with WordGames? You wrote your first lines of code in this course in WordGames.You wrote your first.
Fundamentals of Software Development 1Slide 1 Recap: Key ideas in WordGames Defining a classDefining a class Extending a class versus implementing an interfaceExtending.
EEL 3801 Part VIII Fundamentals of C and C++ Programming Template Functions and Classes.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
Object-Oriented Analysis and Design An Introduction.
Abstract Factory Design Pattern making abstract things.
Sayed Ahmed Computer Engineering, BUET, Bangladesh Masters from the University of Manitoba, Canada
1 Forward and Reverse Engineering. 2 The UML is not just an OO modeling language. It also permits forward engineering (FE) and reverse engineering (RE).
Interfaces. Joseph Sant Sheridan College.. Objectives Discuss reasoning behind interfaces using a scenario. Interfaces and Contracts. Syntax examples.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Inheritance. Inheritance is a fundamental object-oriented design technique used to create and organize reusable classes Chapter 8 focuses on: deriving.
ITF11006.NET Generics. Generics - Sample Recent Generics - Characteristics Performance Type Safety Binary Code Reuse Code Bloat Naming Guidelines.
COMP 121 Week 8: Generic Collections. Objectives To understand type variables and how they are used in generic programming To be able to implement and.
Coming up: Inheritance
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Side effects A side effect is anything that happens in a method other than computing and/or returning a value. Example: public class hello { public int.
 Implementing a class ◦ Implementing an interface ◦ Using documented stubs before coding ◦ Writing JUnit tests before coding ◦ Using fields CSSE 220 Object-Oriented.
Further Abstraction Techniques Chapter 10. Abstract Classes There are times when you do not want someone to be able to make an object of your class. For.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Outline Creating Subclasses Overriding Methods Class Hierarchies Inheritance.
My Wonderful World of Stuff This is a sample slide upload.
SUBCLASSES - JAVA. The Purpose of Subclasses Class Farm String getOwner() void setOwner(String s) int getSize() void setSize(int s) Class DairyFarm String.
Lecture 5:Interfaces and Abstract Classes Michael Hsu CSULA.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
Lecture 6:Interfaces and Abstract Classes Michael Hsu CSULA.
Inheritance Class Hierarchies SoftUni Team Technical Trainers Software University
COP 3330 Notes 4/13. Today’s Topics UML Class Diagrams.
Fundamentals of Software Development 1Slide 1 Today’s Summary InterfacesInterfaces –What are they? –Why are they important? –How do they relate to WordGames?
Fundamentals of Software Development 1Slide 1 Recap: Key ideas in BallWorlds so far Writing a class:Writing a class: –structure –process Writing methods:Writing.
Recap: Key ideas in WordGames
Recap: The design of Word Games
Project management Software development typically includes:
Interface, Subclass, and Abstract Class Review
Chapter 6: Structured Vs. Object Oriented Analysis and Design.
Interfaces.
Chapter 5: Object Oriented Analysis and Design
Interfaces.
Inheritance, Polymorphism, and Interfaces. Oh My
CSE 1020:Programming by Delegation
Fundamentals of Software Development 1
Introduction to Methods and Interfaces
Presentation transcript:

Fundamentals of Software Development 1Slide 1 Why have interfaces? A Java interface is the “face” that one class shows othersA Java interface is the “face” that one class shows others –An interface contains the signature but not body for each method –Any class that implements an interface must provide the methods listed in the interface So an interface specifies a contractSo an interface specifies a contract public interface ClockRadio { public Time getTime(); public Time getTime(); public void setTime(Time x); public void setTime(Time x); public void setTime(Time x, Station s); public void setTime(Time x, Station s);}

Fundamentals of Software Development 1Slide 2 Why have interfaces? Java interfaces are important because:Java interfaces are important because: –They provide for software reuse. For example: I provide a StringTransformable interfaceI provide a StringTransformable interface You provide classes that implement StringTransformableYou provide classes that implement StringTransformable Our separately-written code works together seamlessly!Our separately-written code works together seamlessly! –They provide genericity. For example: My code declares each of your things as a StringTransformable thingMy code declares each of your things as a StringTransformable thing You provide various implementations of StringTransformableYou provide various implementations of StringTransformable –e.g. Capitalizer, NameDropper, UbbyDubber, … My code is generic – it doesn’t care what implementation of StringTransformable you supply!My code is generic – it doesn’t care what implementation of StringTransformable you supply! public interface ClockRadio { public Time getTime(); public Time getTime(); public void setTime(Time x); public void setTime(Time x); public void setTime(Time x, Station s); public void setTime(Time x, Station s);} Interfaces can (and should) be used as types

Fundamentals of Software Development 1Slide 3 UML class diagram for WordGames CapitalizerNameDropperxxx … StringTransformable transform(String) : String All our stuff The StringTransformable interface is how our code knows how to “connect” to your code