Interfaces.

Slides:



Advertisements
Similar presentations
Stereotypes Stereotypes provide the capability to create a new kind of modeling element. –They can be used to classify or mark modeling elements. –A type.
Advertisements

Chapter 22 Object-Oriented Systems Analysis and Design and UML Systems Analysis and Design Kendall and Kendall Fifth Edition.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Deitel Ch 11-part 1 Java GUIs 1 Java GUIs (Deitel, Chap 14-part1) Focus: Attaching GUI components + event handling  input dialog => only one value for.
COMPONENT DIAGRAM in UML 2.0 Veronica Carrega
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions.
C OMPONENT & D EPLOYMENT D IAGRAMS Hoang Huu Hanh, Hue University hanh-at-hueuni.edu.vn.
UML – Class Diagrams.
1 CS 426 Senior Projects Chapter 19: Interfaces and Components [Arlow & Neustadt 2005] February 28, 2008.
UML - Part 3.
C++ Training Datascope Lawrence D’Antonio Lecture 11 UML.
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix.
Lecture a: Additional UML Models: Package, Activity, Deployment Lecture b: Generalization, Aggregation and Additional Domain Model Notation Copyright W.
Sharif University of Technology1 Design and Use-case Realization Software Engineering Laboratory Fall 2006.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation (Adapted) Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra,
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Unified Modeling Language, Version 2.0
CS 11 java track: lecture 4 This week: arrays interfaces listener classes inner classes GUI callbacks.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 8 Slide 1 Object-oriented and Structured System Models.
Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities have a life of their.
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
CBSE 2014 Modeling Components with UML. Bibliography Modelling components in UML – Main text: Kim Hamilton, Russell Miles, Learning UML 2.0, OReilly,
CPSC 871 John D. McGregor Module 7 Session 1 More UML.
TAL7011 – Lecture 4 UML for Architecture Modeling.
Lecture 1: UML Class Diagram September 12, UML Class Diagrams2 What is a Class Diagram? A class diagram describes the types of objects in the system.
1 Kyung Hee University Diagram Editor : Design View Spring 2001.
Part VII: Design Continuous
Design Model Lecture p6 T120B pavasario sem.
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
Object Oriented Programming.  Interface  Event Handling.
Karolina Muszyńska Based on: S. Wrycza, B. Marcinkowski, K. Wyrzykowski „Język UML 2.0 w modelowaniu SI”
Software Engineering Lecture 8 Object-Oriented Analysis.
COMPONENT DIAGRAM in UML 2.0 Veronica Carrega. PLAN OF TALK  Introduction about components  Components and component diagrams in uml 2.0  Case study.
Chapter 19: Interfaces and Components [Arlow and Neustadt, 2005] University of Nevada, Reno Department of Computer Science & Engineering.
Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A.
1 Here are some quotations to get an overview of the kinds of issues of interest.
Java Swing, Events Readings: Just Java 2: Chap 19 & 21, or Eckel’s Thinking in Java: Chap 14 Slide credits to CMPUT 301, Department of Computing Science.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user interface element (the user interface.
UQC117S2 Graphics Programming Lecture 2 Event Handling Program as a sequence of instructions Event -driven program Need to detect the event and carry out.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Appendix 3 Object-Oriented Analysis and Design
Object-Oriented Modeling
Object-oriented and Structured System Models
Course Outcomes of Object Oriented Modeling Design (17630,C604)
COMPONENT & DEPLOYMENT DIAGRAMS
Object-Oriented Analysis and Design
Systems Analysis and Design With UML 2
Chapter 19: Interfaces and Components
Object Oriented Analysis and Design
Component-Level Design
CBSE 2014 Modeling Components with UML
Lec 3: Object-Oriented Data Modeling
Unified Modeling Language
From Design To Code Oct 25, 2006.
Chapter 20 Object-Oriented Analysis and Design
Appendix A Object-Oriented Analysis and Design
Chapter 19: Interfaces and Components
Chapter 19: Interfaces and Components
Constructors, GUI’s(Using Swing) and ActionListner
Basic OOP Concepts and Terms
Design Yaodong Bi.
Chapter 22 Object-Oriented Systems Analysis and Design and UML
Interfaces and Components
Appendix A Object-Oriented Analysis and Design
Appendix A Object-Oriented Analysis and Design
Chapter 19: Interfaces and Components
Presentation transcript:

Interfaces

Interface ~ Class Class – classification of objects based on common attributes, relations and operations. Interface - categorization based on functionality, i.e.., set of operations. A class which implements an interface agrees on supporting the specified functionality.

Interface ~ Protocol Interface defines ability to play a certain role. A plane can moveUp(), moveDown(),.... the same functionality can be simulated by a flight simulator. Planes and flight simulators are different types of objects - still they implement the same interface (implemented differently). 2

Interface: A Named Set of Operations That Describes Some Behavior (No Implementation) In UML an interface is a named set of operations that characterize (a part of) the behaviour of an element. stereotype interface name ISortable operation compartment interface - iconic form interface - expanded form

Example A register can store objects of classes that have implemented interface IRegisterManageable. Class Person implements (realizes) the interface. <<Interface>> IRegisterManageable Register * read() write() edit() Person name The register calls the operations when needed. The operations could be implement in the following way: read() – the user is prompted for attribute values and stores the values read (e.g., read the name of a person). write() – the attribute values are written so that the user can see them (e.g., write the name of the person). edit() – the user is given the possibility to edit the attribute values (e.g., edit the name of the person).

Example Continues <<Interface>> IRegisterManageable Register * read() write() edit() Person name An object of type Register can be used with different types of objects, it can for instance be used to store Car objects without changing class Register. <<Interface>> IRegisterManageable Register * read() write() edit() Car regno

<<Interface>> Example Continues <<Interface>> IRegisterManageable Register * read() write() edit() Person name Interface notation alternatives – the diagram above has same meaning as the one below. Person Register * name IRegisterManageable

Example Continues relization IStorable Register -reg 0..* 0..* edit() <<Interface>> IStorable Register -reg 0..* 0..* edit() write() <<Interface>> relization read() IStorable edit() write() read() public void read(){ Person terminal.print("Name: "); name = terminal.readLine(); edit() ... write() } read() <<Interface>> ISortable -reg Register isLess(theOther : ISortable) : boolean isEqual(theOther : ISortable) : boolean 0..* isGreater(theOther : ISortable) : boolean SortableRegister Person

A Java Example: Interface ActionListener From the Java documentation: The listener interface for receiving action events. The class that is interested in processing an action event implements this interface, and the object created with that class is registered with a component, using the component's addActionListener method. When the action event occurs, that object's actionPerformed method is invoked. Component Button * <<Interface> ActionListener + addActionListener(actionlistener : ActionListener) actionPerformed(e: ActionEvent) MyListener realize or implements the ActionListener interface UML 2.0 Notation: Button MyListener ActionListener MyListener actionPerformed(e: ActionEvent)

Sequence diagram Corresponding Class Diagram oneListener *

1. Interface Contra Class Example: Part of an air conditioning simulation system Class diagram showing the structure Collaboration diagram showing a possible message sequence

2. Interface Contra Class What kind of classes can substitute the Controller class? If you have single inheritance all subclasses of Controller can take its place. If you have a prefabricated class and you want to use this as a Controller, than you have a problem!

3. Interface Contra Class What kind of classes can substitute the Controller class? If you have multiple inheritance and you have a prefabricated class, e.g. one called SomeBaseClass, that you want to use as a Controller: Make a new class that inherit from Controller and from the prefabricated class.

4. Interface Contra Class A new solution where interfaces are used: No associations directly to a class, everything is going through explicit defined interfaces.

5. Interface Contra Class What kind of classes can substitute the Controller class? Now all classes that implements ITempChangeListener, uses IHeater and uses ICooler can be used as a controller. You achieve much the same with abstract classes and multiple inheritance, but multiple inheritance is not possible in Java!

6. Interface Contra Class Use of component notation: UML 2.0 component: A modular part of a system that encapsulates its contents and whose manifestation is replaceable within its environment. A component defines its behavior in terms of provided and required interfaces. Same as above, but with component notation. IHeater ITempChange- Listener «component» Heater «component» TempSource «component» Controller «component» Cooler ICooler

7. Interface Contra Class Use of interfaces advocates a new way of thinking, now focus is on roles/functionality and not on object types – it is a service/client-way of thinking . It allows more explicit information about “functional dependencies” (groups of operations) to be included in the model. Heater and Cooler is substituted with a HeaterCooler.