Object orientation - 3 Review of Tutorial 2 Encapsulation Reusable Types Inheritance.

Slides:



Advertisements
Similar presentations
Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.
Advertisements

Oracle PL/SQL IV Exceptions Packages.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
Enhanced Entity-Relationship Modeling. Strong and Weak Entity Types Strong entity: Each object is uniquely identifiable using primary key of that entity.
From Class Diagrams to Databases. So far we have considered “objects” Objects have attributes Objects have operations Attributes are the things you record.
Oracle Objects Object Oriented Database Approach.
 SAP AG CSU Chico Working with IMG Copyright 1996, 1997, James R. Mensching, Gail Corbitt Contents of this file are for the exclusive use of the.
UQI107S3 Object Orientation lecture 2. Plan Review Tutorial 1 Testing Mayday development –latlong type, boat type, boats table –procedures 3 Tier application.
ISD3 Chris Wallace Next 6 Weeks Extended Relational Model Object Orientation Matching systems 3 tier architecture Technology.
Object Oriented Data Models L19. Topics Objects in PHP –Generalisation –Polymorphism –Reusable classes –Objects and Databases Next week –Data modelling.
OO - Lecture 4 Tutorial Review Associations Inheritance of Functions Polymorphism.
07/19/04 NorCal OAUG Training Day, Paper 2.4 John Peters, JRPJR, Inc.1 Oracle Workflow Notifications John Peters JRPJR, Inc.
CPT 140 Programming Constructs1 OBJECT ORIENTED TECHNOLOGY Terminology and Basic Concepts.
Object Oriented Software Development
Wind. What is Wind? Wind Wind is moving air. Wind moves at different speeds. –Wind can move slowly. –Wind can move very fast. –Wind can blow gently.
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model.
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
CSC 213 – Large Scale Programming. Why Do We Test?
Choose between Access and Excel Right questions, right program If you’re having trouble choosing between Access and Excel, take a moment to answer an important.
Introduction to Objects Adapted from “TEN STEPS TO OBJECT-SPEAK” a CPT Tech Talk by Joy Starks September 17, 1999.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Porting Implementation of Packet Utilization Standard from ADA to JAVA Annelie Hultman (TEC-EME) Donata Pedrazzani (TEC-EMS) ESA/ESTEC 2004 JPUS de-briefing.
Templates, Databases and Frameworks. Databases: DBI Common database interface for perl Provides a functional,
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Estimating the strength of the wind
Jim Janson. Agenda Evolution of software architectures 3-tier User interfaces Application servers Databases.
Refactoring 2. Admin Blackboard Quiz Acknowledgements Material in this presentation was drawn from Martin Fowler, Refactoring: Improving the Design of.
REFACTORINGREFACTORING. Realities Code evolves substantially during development Requirements changes 1%-4% per month on a project Current methodologies.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
CPS Inheritance and the Yahtzee program l In version of Yahtzee given previously, scorecard.h held information about every score-card entry, e.g.,
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
1 CS Programming Languages Class 22 November 14, 2000.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
CPS120: Introduction to Computer Science Lecture 16 Data Structures, OOP & Advanced Strings.
Logical Database Design and the Relational Model.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
COP INTERMEDIATE JAVA Inheritance, Polymorphism, Interfaces.
Objects in the Trenches Steven M. Bray RMOUG Training Days 2004.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
For more course tutorials visit CIS 336 All iLabs Week 1 to Week 7 Devry University CIS 336: All iLabs Week 1 to Week 7: Devry University.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Object Oriented Analysis -- A Historical View “Data Processing” Era: Processes Stored in Programs Data in Associated Files Payroll Payroll Data Purchasing.
Modern Programming Tools And Techniques-I
Programming Logic and Design Seventh Edition
CS320 Web and Internet Programming SQL and MySQL
JAVA By Waqas.
EE2E1. JAVA Programming Revision Lecture.
OOP What is problem? Solution? OOP
How to pass Oracle 1z0-808 exam in first attempt?
Programming the Web using XHTML and JavaScript
CIS 336 strCompetitive Success/tutorialrank.com
CIS 336 str Education for Service-- tutorialrank.com.
IFS410: Advanced Analysis and Design
Object-Oriented Programming
Lesson Objectives Aims Key Words:
Improving the structure of existing code
Abstract Classes Page
Object-Oriented Programming
PL/SQL week10.
Object-Oriented Programming
Object-Oriented PHP (1)
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

Object orientation - 3 Review of Tutorial 2 Encapsulation Reusable Types Inheritance

Tutorial 2 System installation - packaging: –Release of my database to you was rather simple - just copy these files and then run these scripts in Oracle and create this page –But what if we had to deliver this application to a customer to be installed on their system? Changing the application - dependencies: –Modifying the procedures isn’t enough- you have to recompile them because they run in the database –you may have to drop types and tables as well - all in the right order An answer to the last part on the web

Encapsulation -1 in Oracle, you can access the instance variables from outside: –target.pos.latitude.degrees but what if we decide we want to change the way data is stored –not degrees and minutes but –minutes only can’t change the attributes now because we would have to change all programs which use this type (clients) too

Encapsulation -2 Better to hide the attributes, and only allow access via functions –target.position.latitude.getDegrees() –target.position.latitude.getMinutes() now can change the internal storage withou affecting clients This is ENCAPSULATION Not possible in Oracle - all attributes ‘public’ Java has better access control and multiple constructors

Types and Records The boat type can be simply implemented in a Relational table as follows Boat typeBoat Record name : varcharname : Varchar degrees : number latitude :dm minutes : real pos: latlong degrees : number longitude :dm minutes : real But not all types can be mapped onto a fixed record. We also need variable length records.

Reusable Types The types we have created are useful in any application dealing with points on the earth’s surface These are re-usable - beyond the Mayday application Reusable types –speed up development –should be fully tested –make systems easier to understand but sometimes we have to work to make a good reusable type ….

0 0 < 1Calm Light air Light breeze Gentle breeze Moderate breeze Fresh breeze Strong breeze Near gale Gale Strong gale Storm Violent storm 1212>= 64Hurricane Beaufort Scale

Degree classification fail pass rd st

Using a Relational DB Grade table class min max fail034 pass3539 3rd4049 Student table name mark fred38 sally57 Getting the class select name, class from student, grade where mark between min and max;

Common problems Converting a wind speed in Beaufort scale –25 knots is Force 6 Converting average mark on degree to an Honours classification –56 marks is a 2.1

fail pass 3rd st Honours Grades topmark mark class classInterval class classlist classification name

create type classinterval as object ( topmark number, class varchar(50) ); create type classList as varray(20) of classinterval; create type classification as object ( name varchar(50), steps classList, member function getclass(mark number) return varchar); create type body classification as member function getclass(mark number) return varchar is begin for i in 1..steps.count loop if (mark <= steps(i).topmark) then return steps(i).class; end if; end loop; return null; end;

Creating a classification object create table Class of classification; insert into Class values ( 'Honours Grades', classList( classInterval(34,'fail'), classInterval(39,'pass'), classInterval(49,'3rd'), classInterval(59,'2.2’), classInterval(69,'2.1'), classInterval(100,'1st') ) );

Reusable Types This Classification type is OK for Honours grades But can we use it for Beaufort scale too?. Three approaches –Use Classification type (but the names will all be wrong) –Create another similar type with ‘wind’ name (wasted work) –Generalise the Classification type with more neutral names (can be hard to find good names and not so readable) We can generalise the names –classInterval > step –topmark > limit –class > value –classList > stepList –classification > stepFunction –getClass() > getValue()

Reusable Type

Where can we use this type Honours grades Beaufort scale Salary grades Discount rates for multiple purchase Tax rate bands...

Inheritance We want to add reports to the boats application. Every report will contain a date, a time, and (usually) a position Specific reports include: –position reports with speed and direction –weather reports with wind speed and direction –warnings with position and time of observation –trouble report with nature and severity of problem

Possible solutions Have separate tables for each type of report –hard to create a chronological log of all reports Have one table, with every possible attribute –big rows, lots of unused columns, hard to know which ones are supposed to be relevant Define a common type and specialised sub- types

Defining a type and subtype create or replace type Report as object( boatname varchar(50), datetime date, position latlong) not instantiable not final ; / show errors create or replace type warningReport under Report( obsdatetime date, obsPosition latlong ); / abstract supertype subtype

Subtype inherits the types attributes warningReport attributes boatname varchar(50), datetime date, position latlong obsdatetime date, obsPosition latlong Inherited from Report Specific to warningReport

Create log and insert reports create table log of report; insert into log values (warningreport( 'Perdika', to_date('03-feb-12:17:40','yy-mon-dd:hh24:mi'), latlong(dm(34,23),dm(21,00)), to_date('03-feb-10:11:50','yy-mon-dd:hh24:mi'), latlong(dm(33,10),dm(20,00)) ) ); insert into log values (positionreport( 'Perdika', to_date('03-feb-12:17:45','yy-mon-dd:hh24:mi'), latlong(dm(34,23),dm(21,00)), 25, 90) );

Next week Tutorial –work with tutor to design some of the improvements - –draw a diagram –don’t need to implement Lecture –Association –Inheritance of functions –Polymorphism