Development of Rigorous Adaptive Information Systems

74
Rigoros and Adap tive ... Information Systems 1 Development of Rigorous Adaptive Information Systems Dr. Nasreddine Aoumeur FIN, ITI, DB group [email protected] Course Site: wwwiti.cs.uni-magdeburg.de/~aoumeur wwwiti.cs.uni-magdeburg.de/iti_db/lehre/oois/inde

description

Development of Rigorous Adaptive Information Systems. Dr. Nasreddine Aoumeur FIN, ITI, DB group [email protected] Course Site: wwwiti.cs.uni-magdeburg.de/~aoumeur wwwiti.cs.uni-magdeburg.de/iti_db/lehre/oois/inde. Information Systems: Working definition. - PowerPoint PPT Presentation

Transcript of Development of Rigorous Adaptive Information Systems

Page 1: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 1

Development of Rigorous Adaptive Information

Systems

Dr. Nasreddine AoumeurFIN, ITI, DB group

[email protected]

Course Site: wwwiti.cs.uni-magdeburg.de/~aoumeur wwwiti.cs.uni-magdeburg.de/iti_db/lehre/oois/inde

Page 2: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 2

Information Systems: Working Information Systems: Working definitiondefinition

– reactive systems (i.e. in continuous interaction with their environment), with

– large amount of immutable and non-immutable data (i.e. fixed and changing) and, with

– processes and activities for exhibiting behaviors on these (state-less and –full) data.

Page 3: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 3

Conceptual Modelling of IS in general

State-less and -ful DATA

Processes and Rules

Structural aspects

Behavioural aspects

E /R or Object paradigm

Petri Nets

Page 4: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 4

Conceptual Modelling of IS in UMLState-less and stateful DATA- Use Cases

- Class Diagrams

- Object Diagrams -Object Constraint Language

Processes and Rules- Sequence Diagrams

- Collaboration Diagrams

- State Diagrams

- Activity Diagrams- Component / deployment diagrams (implementation)

Stru

ctural asp

ectsB

ehavio

ural asp

ects

Forall C in ….

Page 5: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 5

Information system

View-orientedsystem modelling

Airport Flight

Passenger

UML diagrams

partial views

Use case ArrivalIncludes Landing Description The plane is landing. Then the passengers deplane and the luggage is unloaded. If the passenger has luggage then the passenger claims its luggage.

Conceptual Modelling of IS in UML

. . . .

Page 6: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 6

The origins of UMLUML resulted from the merging of three very popular OOD methods ----The three-Amigos

Booch’s OOD

Rumbaugh’s OMT

This focused on the external actors interacting with the system and their functional requirements.. A CASE tool called Objectory is available.

Booch’s method developed originally in 1991 based on OO Diagrams rather complex and CASE tool support essential. Theemphasis here was on design and implementation.

Object modeling technique supported by OMTool. Very Straightforward approach with an excellent text book. Widely adopted in academia and industry alike. Focus very much on analysis rather than design and implementation.

UML : Overview and History

Jacobson’s Use-Case approach

Page 7: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 7

• A Conceptual Modeling– Used to describe a simplified (abstract)

view of reality – in order to facilitate the design and then

the implementation of object-oriented software systems

• Conceptual Language– UML is primarily a graphical language that

follows a precise syntax.• A UNIFIED

– As By the start of the 90’s there was a flood of modeling languages, each with its own strengths and weaknesses.

UML : Overview and History . . . What is UML

Page 8: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 8

• In 1994 the UML effort officially began as a collaborative effort between Booch and Rumbaugh. Jacobson was soon after included in the effort.

• The goal of UML:– A comprehensive modeling language (all

things to all people) that– Promotion of the communication between

all members of the development effort.

• Version : UML 1.0 …. UML 2.0 (2003)

UML : Overview and History . . When is UML

Page 9: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 9

• UML is a language– Conforms to specific rules.– Allows the creation of (structural, behavioural, and

functional) various models.– Does not tell which models need to be created.

• UML is a language for visualizing– UML is a graphical language.– Pictures facilitate communication (a picture is worth

a thousand words)• UML is a language for constructing and

understanding– UML supports both forward and reverse

engineering.• UML is a language for supporting analysis,

specification and design• UML is intended primarily for software-

intensive information systems

UML : Overview and History . . What is UML

Page 10: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 10

• Diagrams: – Structural aspects :

» Class and object diagrams » Component and deployment (implementation)» OCL (object constraints language) for invariants,

pre- and post-conditions.– Behavioural aspects :

» Use cases, » Statechart, » Activity diagrams» Sequence diagrams

• A set of standardised diagramatic notations for representing different aspects of a (information) system. Containing static structural views, dynamic behavioural views and functional views

UML : Overview and History . . What is UML

Page 11: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 11

The Unified Modelling Language

• A design method or process, neither is it a methodology. There is no provision for project management specification of deliverables or life cycle or provision for estimation

• Users, developers can uses - Whatever process and life cycle – RAD they want

- Focus on Prototyping / incremental development - Focus on waterfall or spiral - they wished and - Provide their own project management and QA framework.

UML : Overview and History . . UML is NOT

Page 12: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 12

Static, structure diagrams• Class and instance diagrams

- These depict the components (classes or instances) within the system,- Their attributes and methods and their relationships with each other- The class diagram in particular is the most important single diagram in the design- Plus OCL constraints on invariants pre- and post-conditions

on methods• Component and subsystem diagrams (implementation) - How classes are grouped to form large assemblies - reusable components, sub-systems or packages of classes.• Deployment diagrams (implementation) - How the software components are deployed across a set of hardware components.

UML : Overview and History . . Inside UML

Page 13: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 13

Interaction diagrams• Use-case diagrams - Show the interface between the system and the outside world - Identify the actors in the system and their required functionality.• Sequence diagrams - Capture the functionality of the system suing the messages passing between objects. - Each sequence diagram shows the implementation of one scenario• Collaboration diagrams - Based on the instance diagram, it shows how specific scenarios are implemented by message sequence. - Similar to sequence diagrams but with more detail

UML : Overview and History . . Inside UML

Page 14: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 14

Dynamic behaviour of the system• Activity diagrams - Similar to Petri-nets, - Provide a view of the way objects interact and changes their states in consequence - The emphasis here is on system functionality as perceived by users• Statecharts - Harel Statecharts are developed from finite state notation - Illustrate the dynamic behaviour of objects. i.e. the way in which an object evolves through time - in response to external events.

UML : Overview and History . . Inside UML

Page 15: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 15

Most diagram types are involved, but principally at the conceptual level :

1. Conceive a use-case diagram - identify actors

- identify major functional requirements2. Conceive an initial Class diagram

- discover principle classes - represent important relationships

3. Event sequence diagrams - Examine possible object interactions - Determine class protocols At Implementation model different refinements are to undertake - combining or splitting classes, - adding or removing relationships, -defining the implementation of relationships, - introducing generalisations, interfaces - Introduce Component, sub-system and deployment models.

UML : Overview and History . . UML for IS

Page 16: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 16

A use case ... – Specifies what system will be used for, before the

defining what system is supposed to do– Describe functionality of a system yielding observable

results– Details scenarios that describe the interaction/dialog

between users of the system and the system itself. Identify who (or what) interacts with the system

– Does not indicate how the specified behavior is implemented, only what the abstract behavior is.

– Performs a service for some users of the system.» A user of the system is known as an actor.» An actor can be a person or another system.

– During the conceptual phase » Facilitates communication between the users and

developers of the system.» Facilitates the goal-based understanding of the

system

UML : Use Cases Overview and illustrations

Page 17: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 17

UML : Use Cases Basic artifacts

An Actor is consistent set of roles that user plays when interacting with the system (e.g. a user or outsider of the system that interacts with the system)

Actor Relationship UseCaseName

A link between the actors and the functions (use-cases). Different relationships are possible.

A Use Cases a sequence of actions performed by a system that yields a valuable result for a particular actor

Page 18: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 18

UML : Use Cases basic artifacts

System defines the boundary between the system and the actors interacting with the system and other systems

System

Page 19: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 19

• Model with use cases essencial parts of system functionality

• Model only those actors who involved in Use Cases

• Factor out common functionality using inheritance relationship <<include>>, <<extend>> stereotypes

• Describe only those events which are visible for the actor

• Each use case should describes a significant piece of system usage understandable by domain experts

• Use nouns and verbs accurately to help deriving objects and messages for interaction diagrams afterwards

UML : Use Cases---Modelling guidelines

Page 20: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 20

Specifies the participation of an actor in a Use Case

ActorUse Case

Association

Generalization

A taxonomic relationship between a less and a more general Use Case

UML : Use Cases basic artifacts

Page 21: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 21

<<extend>>

Extend a relationship

Specifies how the behaviour of the extension use cases e can be inserted into the behaviour of the base use case b

<<include>>

specialize a relationship

Specifies how the behaviour of the included p contributes to the behaviour of the base use case b

e b

pb

UML : Use Cases basic artifacts

Page 22: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 22

Student

Deposit funds

Prepare for examination

Louis acts as a student

Enroll for a course

Elen acts as a student

UML : Use Cases actors illustrations

Page 23: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 23

Student

Deposit funds

Prepare for Examination

Louis acts as a student

Enroll for a Course

Louis acts as a customer

customer

UML : Use Cases actors illustrations

Page 24: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 24

• Use case Arrival• Includes Landing• Actors plane, passenger• Preconditions non• Description The plane is landing.

Then the passengers deplane and the luggage is unloaded. If the passenger has luggage then the passenger claims its luggage.

UML : Use Cases --- AIRPORT illustration

Page 25: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 25

ArrivalPassenger

Departure TakingOff

Landing Plane

<<include>>

Airport

Flight

use caseuse case

actoractor

<<include>>

UML : Use Cases --- AIRPORT illustration

Page 26: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 26

Bank Consortium

Deposit

Withdraw Cash

Automated Teller Machine (ATM)

Transfer Funds

Maintain ATM MaintenanceCrew

Customer

UML : Use Cases --- ATM use illustration

Page 27: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 27

Use Cases Scenarien

• Ask the following questions:– What are the primary tasks that the system is

supposed to perform?– What data will the actor manipulate (add, store,

change or remove) in the system?– Which external changes does the system need

to know about?– Which changes or events will the actor of the

system need to be informed about?

Page 28: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 28

UML

Structural Modelling

Page 29: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 29

Use Cases : Introduction

Page 30: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 30

• A use case ... – Represents a functional requirement of the system

as a whole.– Is graphically represented as an oval with the name

of its functionality written inside.» Functionality is always expressed as a verb or a

verb phrase.• An actor is most typically represented as a

stick figure of a person labeled with its role name.

• Individual use cases can exist in relationships with other use cases much in the same way as classes maintain relationships with other classes.

Use Cases : Introduction

Page 31: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 31

• Names are used to distinguish one use case from another.

• Actors …– May be drawn as a stick figure, stereotyped class or

a graphical image of your own design.– Are connected to use cases by associations.– May be involved in generalization relationships with

other actors.– Exist outside the system boundaries (the

environment).

Terms and Concepts

Page 32: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 32

The Unified Modelling Language

Use-case diagramsThese depict the Actors in the system and the required functionality.

Actors

External entities People interested in system Other systems interfacing with the systemMay or may not be represented by a software component.Represented by stick people or other graphic.

Functions

Primary functionality of system seen from a users perspective.Linked to the actors involved with/interested in the function.Represented by ovals.

Page 33: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 33

Terms and Concepts

Page 34: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 34

• Use cases and Flow of Events– A use case, by itself, does not describe the flow of

events needed to carry out the use case.– Flow of events can be described using informal text,

pseudocode, or activity diagrams.– Use a note to attach flow of events documentation to

a use case.

Terms and Concepts

Page 35: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 35

The Unified Modelling Language

Use-case for library system

Returnbook

Staffborrower

studentborrower

Checkmember status

Reservebook

Browsecatalogue

Borrowbook

browser

Counterstaff

manager

Registermember

Usagereport

Updatecatalogue

Return late book

<<uses>>

<<uses>>

<<extends>>

Page 36: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 36

Terms and Concepts

• Organizing Use Cases– Packages may be used to organize (group) use

cases.– Generalization between use cases is used to extend

the behavior of a parent use case.– An <<include>> relationship between use cases

means that the base use case explicitly incorporates the behavior of another use case at a location specified in the base.

» Sometimes the <<uses> stereotype is used instead of <<include>>.

Page 37: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 37

Use Case Relationships

Page 38: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 38

Use Case Relationships

Page 39: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 39

• Use case diagrams …– Show a set of actors, use cases, and their

relationships.– Facilitate communication between non-technical

customers and developers due to their simplistic nature.

– Show the functionality of the system from the prospective of each user of the system.

– Model the context of the system.– Model the requirements of the system.

Use case diagrams

Page 40: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 40

Use Case Diagram

Page 41: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 41

Generating Use case diagrams

• To model the requirements of a system …– Identify all actors (users of the system).– Identify the needs, from the system, of each

individual actor.– Make each need a use case.– Identify redundant behavior within your set of use

cases, and factor it into common base-class use cases ( generalization ) .

– Do the same for actors.– Show the relationships between actors and use

cases.

Page 42: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 42

Modeling System Context

Page 43: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 43

CMs Generation shift: “Entity To Object”

Processes, Operations and Rules

From E/R to “Object-Object

Entity Name

Attribute1 : Type1

Attribute2 : Type2....Attributei : Typei

Property1

.....

n-m

i-j AssocPART

IS-A

m Entit(ies)

n Entit(ies)

data

data

operation

sop

erations

Page 44: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 44

First generation of CMs : “Entity first”E/R Conceptual Model

Customer

Name : StringBirth-Date : DateAddress : AddressIncome : Money

Open-Date

Bank

1-20-N Own

(Running) Account

Number : NatBalance : MoneyLimit : MoneyHistory : List[Date,Money]

IS-A

Saving Account

Number : NatInterest : PercentBalance

Processes and RulesAccount USE : First open --- then deposit – then (withdraw-deposit)* - then Close-or-be-closed

Page 45: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 45

CMs generation shift : “From Entity to object”From E/R to Object Model : Banking Example

Customer

Name : StringBirth-Date : DateAddress : AddressIncome : Money Open-Date

Bank

1-20-N Own

(Running) Account

Number : NatBalance : MoneyLimit : MoneyHistory : List[Date,Money]

Processes,operations and RulesAccount USE: First open - then deposit –> then (withdraw-deposit)* --> then Close-or-be-closed

+op

en- closed

eposit

with

draw

+open (date, bank)-close(date)-Debit(Amount)-Credit(Amount)

Own(account) : Boolean Deposit (amount) Withdraw(Amount)

Page 46: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 46

CM Generation shift : “From Entity to Object”From E/R Model to Object : ATM example

CustomerName : String

Amount

Date

1-20-N

Withdraw

AutomaticTellerMachine

ATM-Reference : StringCash : HiddenBank : StringTransaction : List[Money]History :List[Card-Nb,Acnt-Nb,Money

Bank-Card

Number : NatAccount-Nb: NatCode : String

Processes, operations and RulesATM-use : First enter-card – then enter-code – then enter-transaction— get money

- Read-card()- Enter-Pin(Code)- Enter-Amount(Money)- Get-Money(Money)

-Create()- Delete()- Accepted()- Rejected()

En

ter-cardE

nter-cod

een

ter-amou

nt

Get-m

oney

-Withdraw (ac, amount)- deposit (ac, amount)

Page 47: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 47

CM Generation shift: “From Entity to Object”From E/R Model to Object : The Library Example

Student

Name : StringSubscription-NbSemester Date-Out

Date-Back

0-N0-3 Borrow

Book

Reference : StringName : StringAuthor : StringPublisher : String

Processes, operations and RulesFirst subscribe-- Get library-card – (Borrow – Return –or– Penality)*--(be)Unsubscribe(d)

- Add()- Suppress()- ToBorrow(Date)- ToReturn(Date)

- Subscribe2Library- Unsubscribe-GetCard- ReceivePenalty

Su

bscrib

eU

nsu

bscrib

eB

orrowR

eturn

Pen

ality

Page 48: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 48

In real world terms:• An object represents an individual entity or

thing.• A class represents a group of objects that

exhibit some common characteristics or behavior.

• Classes are resulted from classification.

OO phylosophy : The real-world consists in a society of interacting objects.

• Examples of classes in real world:– Students– Graduate students– Undergraduate students – MS students– Ph.D. students

Object-Oriented Paradigm : General Overview

Page 49: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 49

• An object has– state: defined by the set of fields or

attributes.– behavior: defined by the set of methods or

operation that can be applied to the object.– identity: determined at the creation time to

uniquely referencing the object.

• Class– A template for creating objects.– Objects of the same class exhibit the same

behavior. – But generally, they posses different states

(attribute values)

Object-Oriented Paradigm : Main concepts

Page 50: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 50

Like in real world:

Book

one can

• Id : IF-43342• Title : „Petri Nets“• Author : „W.Reisig“• State :{available, borrowed, use..}

Object

has

Attributs (state)

Methods(behaviour)

• borrowed• returned• edited• .....

Object-Oriented Paradigm : Main concepts Object and Class

Page 51: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 51

The class MyDate The object d is an instance

of class MyDate

MyDate d:MyDate fieldsday (or:,variables day = 31month state month = 1year attributes) year = 2000

set (d,m,y) set (d,m,y)incDays (nDays) methods incDays (nDays)getWeekDay ( ) getWeekDay ()

Object-Oriented Paradigm : Main concepts

object-class

Page 52: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 52

The class Accounts The object Ac-Nasr instance

Account Ac-Nasr : Account

Number balance (fields, variables Number =

3130888limit state Balance = 1200history attributes) Limit = 20 History =

[20.2.2.07,…]

methods

+ open- Close- debit(amount)- Credit(amount- Tranfer(ac1,ac2)

Object-Oriented Paradigm : Main concepts Object-Class

+ openClose debit(amount)Credit(amountTranfer(ac1,ac2)

Page 53: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 53

- Pin(Id)

debit(Id, Money)

- Balance(Bal) : Money

- Limit(Lm) : Money

- History(Hs) :List[M.D]

The Account Class

credit(Id, Money)

- Transaction(Tr)

- AcntNb(AcN)

- CardNb(AcN)

Insert_Code(InsC)(C)

- Store(Sr) : Money

- State(St) : State

The ATM Class

Insert-Card(InC)()

Choose_Trans(CTr)(M)

Object-Oriented Paradigm : Main concepts Encapsulation

Page 54: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 54

• In general all attributes should be private. • Use EXCLUSIVELY methods such as debit

and credit to access the internal state. • Only methods that are part of the

“interface” should be public. • Instance variables and methods are

visibile within that object and other instances of the class.

• With respect to other objects and classes scope can be modified– private : accessible only within the

concerned class– protected : could be changed at subclasses– public : could be manipulated

everywhere

Object-Oriented Paradigm : Main concepts Encapsulation Principles

Page 55: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 55

ENCAPSULATION

class MyDate { private int day, month, year; public void set (int d, int m, int y) {day=d, month= m, year= y … } public void incDays (int nDays) {. . .} public int getWeekDay ( ) { . . . }}

class OtherClass { void anyMethod { MyDate d = new MyDate ( ) ; d.set (09, 5, 2007) ; d.month = 3; // COMPILATION ERROR !!! }}

Object-Oriented Paradigm : Main concepts Encapsulation At-work

Page 56: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 56

//without encapsulation:

circle k = new circle();k.radius = – 88;// radius negative!

//with encapsulationcircle k = new circle();boolean b =

k.setRadius(– 88);// radius never negative!

class circle{double radius, middlepointX, middlepointY;boolean setRadius(double newRadius){

if(newRadius > 0){radius = newRadius;return true;}

else return false; }

}

Object-Oriented Paradigm : Main concepts Encapsulation At-work

Page 57: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 57

A mechanism to organize classes by commonalities.– subclasses, specialization– superclass, generalization

• Is-a relationExample:

– A graduate student is a student.– A Master student is a graduate student.– A Ph.D. student is a graduate student.– An undergraduate student is a student.

Object-Oriented Paradigm : Main concepts Inheritance Concept

Page 58: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 58

Student

GraduateStudent UndergraduateStudent

MasterStudent PhDStudent

Object-Oriented Paradigm : Main concepts Inheritance concept and illustration

Page 59: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 59

Object-Oriented Paradigm : Main concepts Inheritance concept and illustration Running Account

Number : NatBalance : MoneyLimit : MoneyHistory : List[Date,Money]

+open (date, bank)-close(date)-Debit(Amount)-Credit(Amount)

Saving Account

Interest : PercentBalanceSav : Money

+open (date, bank)-close(date)- IncreaseInterest(Percent)- Money(money,account)

Page 60: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 60

Object-Oriented Paradigm : Main concepts Inheritance concept and illustration (ordinary) book

NumberCode : NatTitle : StringStatus : {available, borrrowed.}NumberCopies : Natural

Toborrow (date)-ToReturn(Date)

ThesisFieldSupervisorMarkDate-defenseGetCoppy

Periodics

EtidorsPublisher

Online-Publications

URLDurationsubscription

+subscribe- unsubscribe

Page 61: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 61

Base

Derived

class Base { Base(){} Base(int i) {} protected void foo() {…}}

class Derived extends Base { protected void foo() {…} Derived(int i) { super(i);… super.foo(); }}

As opposed to C++, it is possible to inherit only from ONE class.Pros avoids many potential problems and bugs.Cons might cause code replication

Object-Oriented Paradigm : Main concepts Inheritance at work

Page 62: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 62

Overloading:• Two or more

methods/constructors with the same name but different numbers or different types of parameters:

void methodB(int i) void methodB(float f)

Overriding– Replacing the implementation of a methods

in the superclass with one of your own.– You can only override a method with the

same signature.

Please Avoid overloading !!!!

Object-Oriented Paradigm:Main constructions Overloading and Polymorphism concept

Page 63: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 63

Object-Oriented Paradigm:Main constructions Overloading and Polymorphism concept

Polymorphism:• Inheritance creates an “is a”

relation:• For example, if B inherits from A,

then we say that “B is kind of an A”.• A same method same defined in the

class hierarchy• How to dynamically choose the right

methods ?

Page 64: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 64

GuiComponent width:int height:int center:point setOptimalSize( ) moveTo(newX, newY)

Editbox Scrollbar

minValue text: String

maxValue getValue( ) append(String)

setOptimalSize( ) getText( )

Object-Oriented Paradigm:Main constructions Polymorphism concept

Page 65: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 65

A subclass inherits all members of its superclass:

Variabls Methods

A subclass can: Add more variables Add more methods Override methods of its superclass

Scrollbar sb = new Scrollbar ( ) ; Q : What are the variables of sb? What are the methods that sb can

execute?

Object-Oriented Paradigm:Main constructions Polymorphism at-work

Page 66: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 66

GuiComponent g ; if (scrollbarWasSelected) g = new Scrollbar ( ) ; else g = new EditBox ( ) ;

g.setOptimalSize ( ) ; / / dynamic binding

• A reference to a superclass can point to objects

of its subclasses.• The pointer g is a polymorphic pointer.

Object-Oriented Paradigm:Main constructions Polymorphic Dynamic binding

Page 67: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 67

GuiComponent [ ] ga = new GuiComponent [3] ; ga[0] = new Scrollbar ( ) ; ga[1] = new Scrollbar ( ) ; ga[2] = new EditBox ( ) ; for (int i=0 ; i<ga.length ; i++) { ga[i] . setOptimalSize ( ) ; //line 6}

Q: Which version of setOptimalSize is called in line 6?

Polymorphism allows us to work with an object

without knowing its exact type

Object-Oriented Paradigm:Main constructions Complex Polymorphic Dynamic binding

Page 68: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 68

CASTING

class GuiComponent { void setOptimalSize ( ) { . . . } } class Scrollbar extends GuiComponent { void setOptimalSize ( ) { . . . } int getMinValue ( ) {. . . }

} guiComponent g ; g = new Scrollbar ( ) ;

Suppose we know that g currently points to a Scrollbar, and we want to call: n = g.getMinValue ( ) ;This will cause a compilation error (why?) …. Casting

problem

Object-Oriented Paradigm:Main constructions Polymorphism at-work (casting problem)

Page 69: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 69

The solution is casting (actually down casting).

Casting = convert a variable from one type to another.

Down Casting = convert from a superclass to one of its subclasses.

sb = ( (Scrollbar) g).getMinValue ( ) ;

Or:Scrollbar sb = (Scrollbar) g ;sb.getMinValue ( ) ;

We “tell” the compiler that g currently points to a Scrollbar.

if g does not currently point to a Scrollbar, a ClassCastException is thrown.

Object-Oriented Paradigm:Main constructions Polymorphism at-work (casting problem)

Page 70: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 70

C D

C D

association

aggregationwhole parta stronger form of association

C DcompositionIf an object d of class D is related to an object c of class C, then d depends existencialy on c.a stronger form of aggregation

C D directed association

Object-Oriented Paradigm:Main constructions Association Types

Page 71: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 71

Association EndsC D Each object of class C is related

to 1 to 5 objects of class DEach object of class D is related to exactly one object of class C

1 1..5

C DEach object of class C is related to at least one object of class DEach object of class D is related to arbitrary many objects of class C

* 1..*

C D Associated objects of class D are ordered*

{ordered}

1..*

Object-Oriented Paradigm:Main constructions Association Types

Page 72: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 72

Line Point

roleused to navigate

0..1 2

lRole determine -pRole

association name

direction2 points determine a line

directed aggregation

Object-Oriented Paradigm:Main constructions Association Types

Page 73: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 73

Class Diagrams

C D

C D InheritanceClass C inherits from class D

dependency relationshipClass C depends on class D

Object-Oriented Paradigm:Main constructions Association Types

Page 74: Development of Rigorous Adaptive Information Systems

Rigoros and Adaptive ... Information Systems 74

Engine Brakes Wheel Searing Wheel

Car

1..1 1..4 41..1 4 1

Object-Oriented Paradigm:Main constructions Association Types : Aggregation