Chih-Ping Chu Dept. of Computer Science & Information Engineering

Slides:



Advertisements
Similar presentations
Object-Oriented Design I : Structural UML
Advertisements

UML an overview.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Computer Science Dept. Fall 2003 Object models Object models describe the system in terms of object classes An object class is an abstraction over a set.
Department of computer science N. Harika. Inheritance Inheritance is a fundamental Object Oriented concept A class can be defined as a "subclass" of another.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes (continued)
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
UML Class Diagram: class Rectangle
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
ACM/JETT Workshop - August 4-5, 2005 UML Modeling using MagicDraw UML for Java Programmers.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
Chapter 10: Inheritance 1. Inheritance  Inheritance allows a software developer to derive a new class from an existing one  The existing class is called.
Anyone know what type of planes these are? © Lethbridge/Laganière 2005 Chapter 5: Modelling with classes1 Douglas DC-3.
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.
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Chapter 5: Modelling with Classes
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
1 Given the Radio class  We may define other derivative types: Cassette walkman IS-A radio Alarm clock radio IS-A radio Car radio IS-A radio.
1 UML Basic Training. UML Basic training2 Agenda  Definitions: requirements, design  Basics of Unified Modeling Language 1.4  SysML.
Lecture 5: Modelling with Classes. © Lethbridge/Laganière 2005 Chapter 5: Modelling with classes2 5.1 What is UML? The Unified Modelling Language is a.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Dale Roberts Object Oriented Programming using Java - OOD to OOP: ATM Case Study Dale Roberts, Lecturer Computer Science, IUPUI
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
1 Kyung Hee University Modeling with Objects Spring 2001.
Chapter 8 Specialization aka Inheritance. 2 Inheritance  Review of class relationships  Uses – One class uses the services of another class, either.
Chapter 8 Inheritance. 2  Review of class relationships  Uses – One class uses the services of another class, either by making objects of that class.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Computer Science 209 Software Development Inheritance and Composition.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
Class Diagrams Revisited. Parameterized Classes Parameterized Classes - are used to represent relationships between templates.
Modelling with Classes Adapted after : Timothy Lethbridge and Robert Laganiere, Object-Oriented Software Engineering – Practical Software Development using.
1 The Process of Developing Class Diagrams You can create UML models at different stages and with different purposes and levels of details Exploratory.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes Based on Presentations LLOSENG.
SUBCLASSES - JAVA. The Purpose of Subclasses Class Farm String getOwner() void setOwner(String s) int getSize() void setSize(int s) Class DairyFarm String.
IB Computer Science Content developed by Dartford Grammar School Computer Science Department UML.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Modeling with UML – Class Diagrams
Advanced Programming in Java
Object-Oriented Design
Software Design Models UML
Unified Modeling Language (UML)
Chapter 5: Modelling with Classes
Lecture 12 Inheritance.
Objects as a programming concept
Object-Oriented Analysis and Design
Object Oriented Concepts
UML Class Diagram: class Rectangle
Introduction to Object-oriented Program Design
Abstract Classes.
Week 13: Wrap-up Refining Class Diagram and Implementation
Object Oriented Analysis and Design
Interface.
Software Engineering Lecture #11.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Advanced Programming Behnam Hatami Fall 2017.
COMPUTER 2430 Object Oriented Programming and Data Structures I
Object Oriented System Design Class Diagrams
Week 15: Refining Class Diagram and Implementation
Chapter 5: Modelling with Classes
Presentation transcript:

Object-Oriented Software Development: Class Diagrams and Its Implementation Chih-Ping Chu Dept. of Computer Science & Information Engineering National Cheng Kung University

Outline Features of object-oriented software Developing OO systems based on models UML diagrams Essentials of class diagrams Implementing class diagrams

Models are used for: - leading software engineers to have insights about the system - providing abstraction - helping create designs - permitting analysis and review of those designs. (check design) - being the core documentation describing the system.

UML diagrams Class diagrams - describe classes and their relationships Interaction diagrams - show the behaviour of systems in terms of how objects interact with each other State diagrams and activity diagrams - show how systems behave internally Component and deployment diagrams - show how the various components of systems are arranged logically and physically

Class diagrams

Interaction diagrams

State diagrams and activity diagrams

Component and deployment diagrams

Essentials of UML Class Diagrams The main symbols shown on class diagrams are: Classes - represent the types of data themselves Associations - represent linkages between instances of classes Attributes - are simple data found in classes and their instances Operations - represent the functions performed by the classes and their instances Generalizations - group classes into inheritance hierarchies

Implementing Class Diagrams in Java - Attributes are implemented as instance variables - Generalizations are implemented using extends - Interfaces are implemented using implements - Associations are normally implemented using instance variables - Divide each two-way association into two one- way associations so each associated class has an instance variable.

- For a one-way association where the multiplicity at the other end is ‘one’ or ‘optional’ - declare a variable of that class (a reference) - For a one-way association where the multiplicity at the other end is ‘many’: - use a collection class implementing List, such as Vector

An example: A Flight Booking System

An example: A Flight Booking System

Creating an association class, given two existing objects class Passenger { private ArrayList<Booking> bookings = new ArrayList<Booking>(0); private String name; public void makeBooking(SpecificFlight flight, int seatNumber) new Booking(this, flight, seatNumber); } void addLinkToBooking(Booking bookOne) // link booking bookings.add(bookOne);

class Booking //association class { Passenger passenger; // due to one to one relation SpecificFlight flight; //due to one to one relation int seatNumber; Booking(Passenger passenger, SpecificFlight flight, int seatNumber) this.passenger = passenger; this.passenger.addLinkToBooking(this); this.flight = flight; this.flight.addLinkToBooking(this); this.seatNumber = seatNumber; }

void addLinkToBooking(Booking bookOne) booking.add(bookOne); } class SpecificFlight { private ArrayList<Booking> booking = new ArrayList<Booking>(0); private String name; void addLinkToBooking(Booking bookOne) booking.add(bookOne); }

Making a bi-directional link between two existing objects; class SpecificFlight { private Calendar date; private RegularFlight regularFlight; ... // Constructor that should only be called from // addSpecificFlight SpecificFlight( Calendar aDate, RegularFlight aRegularFlight) date = aDate; regularFlight = aRegularFlight; }

class RegularFlight { private List specificFlights; ... // Method that has primary responsibility public void addSpecificFlight(Calendar aDate) SpecificFlight newSpecificFlight; newSpecificFlight = new SpecificFlight(aDate, this); specificFlights.add(newSpecificFlight); }

Creating an object and linking it to an existing object class SpecificFlight { private FlightLog log; private RegularFlight regularFlight; ... public void createFlightLog () log = new FlightLog(); }

class FlightLog { ... FlightLog () // constructor }

Searching for an associated instance import java.util.Iterator; class SpecificFlight { private ArrayList<EmployeeRole> employees = new ArrayList<EmployeeRole>(0); private EmployeeRole anEmployee; ... public EmployeeRole findCrewMember (String name) for (Iterator<EmployeeRole> iterator = employees.iterator(); iterator.hasNext();) anEmployee = (EmployeeRole) iterator.next(); if anEmployee,getname() == name return anEmployee; }

class EmployeeRole { private String name; ... public String getName() return name; } () }